diff options
author | James Yoo | 2022-10-25 18:06:36 +0000 |
---|---|---|
committer | James Yoo | 2022-10-25 18:06:36 +0000 |
commit | 717ac7853efc82e2bb8402ed8408749279bccee9 (patch) | |
tree | ce20c519cd94f469eada4d06933f7a0b2b18beee /entries/jyoo980 | |
parent | 60d5f5781a05275963543c51389fe46dd0243015 (diff) |
Adding AspectJ version of Fibonacci
Diffstat (limited to 'entries/jyoo980')
-rw-r--r-- | entries/jyoo980/aspectj/Fibonacci.aj | 21 |
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; + } +} |