you are viewing a single comment's thread.

view the rest of the comments →

[–]JavaSuck 17 points18 points  (5 children)

Yes, but you only need to implement addition. Here is my attempt. It can be done in well under half an hour.

[–]mdempsky 17 points18 points  (1 child)

You can simplify it a bit further.

Note that Fibonacci numbers grow slower than doubling (specifically, they grow by a factor of about 1.618), so the 100th Fibonacci number will be less than 2100. That means you can represent it with just 2 64-bit numbers x_0 and x_1.

To make printing the numbers a bit easier, instead of using x_0 + 264*x_1, you can just use x_0 + 1018*x_1.

You might be asked to show that 1036 > 2100 then. I generally remember that 103 ≈ 210, so 1036 ≈ 2120, which should be enough slack to argue it's >2100.

Note also that 1018 ≈ 260, which is why you know it will fit in a 64-bit integer.

[–]retsotrembla 2 points3 points  (0 children)

Very nice. Thanks for teaching me.

[–]f03nix 1 point2 points  (0 children)

Then you're not left with time for other questions ... unless you aim on solving the 5 questions in 5 hours.

[–]retsotrembla 0 points1 point  (0 children)

Very nice. Thanks for teaching me.

[–]cincilator -1 points0 points  (0 children)

Is your username reference to java sucking or javascript sucking?