Solving the 2012th term in the Fibonacci Sequence

potatocount

New member
Joined
Sep 1, 2012
Messages
5
Good day Sirs and Madams,

I have a random question, I was thinking about the 2012th term in the Fibonacci Sequence using the nth term formula:

Code:
[B]F(n) = (Phi^n - (-Phi^n)) / sqrt (5)[/B]

[**sorry I don't know how to format the equation correctly. I preview it but still doesn't work.]

yes there is a formula for computing the nth term in the fibonacci how can I compute it if i have such a large n like 2012.
I tried to solve it manually since online calculators and my calculator can't compute such large number.


First
, i tried using LOG just to see how many digits the 2012th term has, and to know how big is the number i'm dealing with. I used this formula:

Code:
[B](n)LOG_10 (Phi) - (log5/2) [/B]

the answer is 420 digits. That's really a big big number.

Second, if my n is 1000, there are very few numbers [22 F Values] to compute to get F(1000) by using the formula in Dijktra's Note (1979) as follows:

Code:
[LIST]
[*][FONT=verdana][SIZE=2]F(1000) needs F(500) and F(499)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(500) and 
F(499) need F(250) and F(249)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(250) and 
F(249) need F(124) and F(125)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(124) needs F(61) and F(62)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(125) needs F(62) and F(63)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(63) needs F(32) and F(31)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(62) and 
F(61) needs F(31) and F(30)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(32) and 
F(31) need F(16) and F(15)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(30) needs F(15) and F(14)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(16) and 
F(15) need F(8) and F(7)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(14) needs F(7) and F(6)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(8) and 
F(7) need F(4) and F(3)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(6) needs F(3) and F(2)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(4) and 
F(3) need F(2) and F(1)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(2) needs F(1) and F(0)[/SIZE][/FONT]
[*][FONT=verdana][SIZE=2]F(1) and 
F(0) are 1 and 0 by definition[/SIZE][/FONT]
[/LIST]

The problem is, I am looking for a way larger term. I am quite stuck on this one and I think I cannot sleep.

I want to prohibit myself from using online Fibonacci Calculators, they can't compute larger nth terms as well.
As much as possible I want to solve this using an ordinary scientific calculator,
if only my calculator could solve Phi^2012 then this wouldn't be much of a problem.

I am pretty much stuck. Anyone wants to shed some light on this one? Thanks!
 
A looper (UBasic) takes less than a second.

a = 0
b = 1
FOR n = 3 to 2012
f = a + b
a = b
b = f
NEXT n
PRINT f, LEN(f)
8407357.............6155559 , 420

Examples:
Term# : Length
1000 : 209
2000 : 418
5000 : 1045
8000 : 1672
12000 : 2508

Thank you Sir Denis for your time on this one.

if it is not much to ask, can you paste the whole string of the 2012th term?

I'd like to use a Looper (UBasic for that matter) but i have little or no knowledge on basic programs like this.
I would still like to try solving, and countercheck my answer. Thank you very much!
 
Sir DENIS,

I tried to use the program UBasic as you mentioned it. although I only have a little knowledge about it
as you can see in my screen cap, i read some forums about uBasic.

Now i have problems when i tried to rewrite the code you used for the Fibonacci, see screen cap:

UBASIC.jpg

i don't understand what will i do with "No For(next)".

also, how can i make the line numbers show? I encountered this code and tested it but it failed.
i think i need to see the line numbers to direct the counter properly.

example:

Code:
[FONT=Verdana]1 REM TO PRINT THE FIBONACCI SERIES TILL 2012[/FONT]
[FONT=Verdana]2 A = 0[/FONT]
[FONT=Verdana]3 B = 1[/FONT]
[FONT=Verdana]4 PRINT A; B;[/FONT]
[FONT=Verdana]5 C = A + B[/FONT]
[FONT=Verdana]6 IF C >= 2012 THEN GOTO 11[/FONT]
[FONT=Verdana]7 A = B[/FONT]
[FONT=Verdana]8 B = C[/FONT]
[FONT=Verdana]9 PRINT C;[/FONT]
[FONT=Verdana]10 GOTO 6[/FONT][FONT=Verdana]
11 END[/FONT]

Do you think this code that would use line numbers could work? Thanks!
 
Top