aboutsummaryrefslogtreecommitdiff
path: root/entries/jyoo980/aspectj
diff options
context:
space:
mode:
authorLily Lin2022-10-26 23:30:06 +0000
committerLily Lin2022-10-26 23:30:06 +0000
commitaf03b3cd051a8a8b1442147136156f271f07ac5c (patch)
tree6239bbd269f8c682fcd2bd1aecd29cc8b2edf6b5 /entries/jyoo980/aspectj
parent66fdac7a5ab7040a29fdd6a49cb0123db5ea916a (diff)
parent18d17f9fb578df5f20e689481ed06f44fcf4b80c (diff)
Merge branch 'main' into lily
Diffstat (limited to 'entries/jyoo980/aspectj')
-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;
+ }
+}