C Sharp Problem 67

Back to Problem Solutions forum

rizk.christopher     2014-11-19 22:53:53

Hey everyone! So, I've not had any issues with these problems thus far, i've solved 21, however I've gotten to problem 67 on fibonacci sequences and have hit a wall. My initial thought would be to create a list of all fibonacci numbers up to the 1000 index limit given and then compare the problem numbers to it and pull those indexes, however with the numbers being as large as they are, I am hitting a wall pretty quickly. Can anyone give me some advice to point me in he right direction? I'm using C# as my language of choice. Thanks!

Rodion (admin)     2014-11-20 06:04:47
User avatar

Hi, thanks for your message!

Your solution should work anyway if you can use some suitable data type for such long numbers.

I believe C# has special class called BigInteger for storing values of arbitrary length. It would not be the most efficient, but with given limits this should work like a charm, if I am not mistaken!

Though later you can find out this problem could be solved even without storing large numbers... ;-)

Please login and solve 5 problems to be able to post at forum