Bigger Fib

Discussion of challenges you have already solved
Post Reply
dotme
Posts: 10
Joined: Sun Nov 16, 2008 6:45 pm

Bigger Fib

Post by dotme »

That was fun.

While solving "Big Fib" with bc driven by a perl-script and using the dijkstra-simplification, I realized that getting the solution for this challenge would take more time and cycles than I want to spent on it.

So, I changed to C with GMP and was really thrilled by the speed of GMP in computing fib members (damn, should have known that before :?) . But GMP lacks ln() so I spent some extra time to bring in MPFR.

.done! (phewww)
brazzy
Posts: 14
Joined: Fri Nov 07, 2008 2:30 am
Location: Munich, Germany
Contact:

Post by brazzy »

You know, a little bit of pretty basic applied math knowledge makes this (and BiggestFib as well) solvable without any fancy libraries in 2 or 3 lines of code and a very small fraction of a second.
homeas
Posts: 10
Joined: Thu Nov 13, 2008 11:17 pm

Post by homeas »

with a little bit knowledge of "sectio aurea" you don't need any coding at all, just the Windows calculator and you'll find the solution manually in only some seconds ...
rmplpmpl
Posts: 113
Joined: Sun Oct 26, 2008 10:38 am
Location: Germany

Post by rmplpmpl »

Phew, finally solved that one... after I got the BigFib I really was shocked by the BiggerFib challenge, a short attempt to calculate this number (w/o thinking about the ln-part too much) led me to the point that this is simply senseless...

It was not until half an hour ago that I read about ways to calculate big f(n) and to recap the laws of logarithmics.

Now on to the biggest fib :)

EDIT: OK, biggest is not really harder than bigger...
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

rmplpmpl wrote:EDIT: OK, biggest is not really harder than bigger...
Except in the sense that "bigger" is fully calculable in a vaguely reasonable time period (a few days, for me) - it wasn't until "biggest" that I took the more efficient approach.
blablaSTX
Posts: 11
Joined: Mon Aug 17, 2009 8:12 pm
Contact:

Post by blablaSTX »

sometimes it helps to "think" before starting to hack in some code !
compuation is done in a few milliseconds if done right.
quangntenemy
Posts: 8
Joined: Thu Jul 02, 2009 3:41 pm

Post by quangntenemy »

Well the ln part makes it easier than expected :D
Millennium
Posts: 17
Joined: Thu Apr 21, 2011 3:08 am

Post by Millennium »

XD I did it in one line

print(150000000*log(1.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475408807538689175212663386222353693179318006076672635443)-.5*log(5))

Which is a way of writing

x*log(phi)-.5*log(5)
moose
Posts: 67
Joined: Fri Jul 16, 2010 7:32 pm

Post by moose »

Wolfram|Alpha did it.

Has anyone solved it with Python? Could you please post your solution? Or any C++ approach? (I would like to learn C++ and I appreciate reading examples)
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

moose wrote:Wolfram|Alpha did it.

Has anyone solved it with Python? Could you please post your solution? Or any C++ approach? (I would like to learn C++ and I appreciate reading examples)
I think most of us probably used the formula for the nth Fibonacci number, ending up with:
-(Log[5]/2) + Log[-(2/(1 + Sqrt[5]))^n + (1/2 (1 + Sqrt[5]))^n]
(WolframAlpha will show this in a nice format).
Then noting that the -(2/(1+Sqrt[5]))^n term will become very close to 0 as n increases, so we end up with:
-(Log[5]/2) + n Log[(1/2 (1 + Sqrt[5]))]
which is very easy to find.
There is no spoon.
User avatar
Hippo
Posts: 339
Joined: Sat Feb 01, 2014 12:05 am
Location: Praha 5

Post by Hippo »

If I remember well, I had opened excell when I came to these 2 challenges. So I have multiplyed and subtracted the logarithms there...
Post Reply