Problem: fibn vector_length_100thousand runs too long (10 hours and
running).
35% of my memory & all swap is available.

The analysis shown indicates the problem could run in well under an
hour.
Did memoize decide the task is impossible?
Discarding the M. cache every now and then might help.
References: ProjectEuler #304, Dijkstra's Fibonacci formula
http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibFormula.html#exact

Thanks, Dave.


$ jconsole
   NB. Least significant figures of large Fibonacci numbers.
   
   (9!:12 ,&(' '&,@":) 9!:14)''  NB. unix j7
 5 j701/2011-01-10/11:25

   ts=: 6!:2, 7!:2@]
   int =: = <.

   fibn_test =: +:@(<&2) + 2&|

   (,. fibn_test)i.6
0 2
1 3
2 0
3 1
4 0
5 1
   
   fibn_even_term =: fibn@-: * +:@fibn@<:@-: + fibn@-:
   fibn_odd_term =: (fibn@<:  +&*: fibn)@-:@>:
   fibn =: (1234567891011x |
fibn_even_term`fibn_odd_term`0:`1:@.fibn_test)M."0

   a=: 1!:1<'e304.primes'
   #primes=:".' '(I.LF=a)}a
100000
   q: primes{~5?#primes
100000001643887
100000000146283
100000003087511
100000000129571
100000000933793
   
   NB.-------------------KEY TIMING RESULT--------------------
   ts'fibn 10{.primes'   NB. could take well under an hour all
0.003889 142592
   
   fibn i.10  NB. fibn is possibly correct
0 1 1 2 3 5 8 13 21 34

   NB. without M.
   fibn=:(1234567891011x |
fibn_even_term`fibn_odd_term`0:`1:@.fibn_test)"0

   ts'fibn {.primes'
longer than I'll wait.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to