aboutsummaryrefslogtreecommitdiff
path: root/entries
diff options
context:
space:
mode:
authorBraxton Hall2022-10-25 20:01:52 +0000
committerGitHub2022-10-25 20:01:52 +0000
commit5ff019bc3205def15e1ee73cd9c60e4c69509750 (patch)
tree6dbcc610636eab7d1301938e7a5a2e16e043a88e /entries
parent51cfdff65b200f3cb16688b79720a1ab57d2db02 (diff)
parent717ac7853efc82e2bb8402ed8408749279bccee9 (diff)
Merge pull request #44 from jyoo980/main
Adding AspectJ version of Fibonacci
Diffstat (limited to 'entries')
-rw-r--r--entries/jyoo980/aspectj/Fibonacci.aj21
1 files changed, 21 insertions, 0 deletions
diff --git a/entries/jyoo980/aspectj/Fibonacci.aj b/entries/jyoo980/aspectj/Fibonacci.aj
new file mode 100644
index 0000000..39dfd8a
--- /dev/null
+++ b/entries/jyoo980/aspectj/Fibonacci.aj
@@ -0,0 +1,21 @@
+public aspect Fibonnacci {
+
+ pointcut mainInvocation(): call(* Main.*(*));
+
+ void before(): mainInvocation() {
+ // Nice
+ int n = 69;
+ System.out.println("The 69th fibonacci number is: " + fibonacci(n));
+ }
+
+ public int fibonacci(int n) {
+ int prev = 0;
+ int curr = 1;
+ for (int i = 0; i < n; i++) {
+ int tmp = prev;
+ prev = curr;
+ curr = prev + tmp;
+ }
+ return prev;
+ }
+}