summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--problem684.ijs22
1 files changed, 4 insertions, 18 deletions
diff --git a/problem684.ijs b/problem684.ijs
index 494c34d..83ce229 100644
--- a/problem684.ijs
+++ b/problem684.ijs
@@ -1,18 +1,4 @@
-modn =: 1000000007
-
-S =: {{
- t =. <.y%9
- k =. 9|y
- pow10 =. 10 modn&|@^t NB. This is effective in J for calculating 10^t mod modn
- (6+y)-~pow10*+/6,k,>:i.k
-}}
-
-fib =: {{
- if. y < 2 do.
- y
- else.
- (fib y-2)+(fib y-1)
- end.
-}} M.
-
-problem684 =: modn|+/S@fib"0 x:2+i.89
+r =: 1000000007
+S =: {{ _6+y-~(10 r&|@^<.y%9)*+/6,2+i.9|y }}"0
+fib =: (-&1 +&$: -&2) ^: (1&<) "0 M.
+problem684 =: r|+/S fib x:2+i.89