[Problem 67] Problem in C with size of input

Back to Problem Solutions forum

NatholBMX     2014-12-14 14:39:14

Hey guys, I can't seem to solve problem number 67. I've written an array with the fibonacci-sequence with the first 1000 values and I want to compare the input against these values. With lower number it's possible without a problem, but as soon as the number gets too big I get a "Segmentation fault (core dumped)" error message from this site.

Any help is appreciated!

nicolas_patrois     2014-12-14 15:23:03
User avatar

Are you sure that C can manage such huge numbers?

Rodion (admin)     2014-12-14 18:55:16
User avatar

Yes, I'm afraid Nicolas is pretty correct - in C/C++ you are to implement "long arithmetic" storing numbers in arrays and writing a function to sum them. However this should not be hard.

nolanh08     2015-08-11 02:55:22

Why are the test-cases so long?

Rodion (admin)     2015-08-11 03:18:47
User avatar

To teach working with long arithmetics in one manner or another :)

nolanh08     2015-08-11 03:32:52

I see. Is using modular arithmetic the preferred method?

Rodion (admin)     2015-08-11 03:40:00
User avatar

No, not neccessarily! I just propose exercises, but everyone can decide what approach to practice if there are more than one :)

Christopher Matthews     2015-08-12 06:45:05

In C, ULLONG_MAX <limits.h> is defined as +18,446,744,073,709,551,615. So, the answer would be to either implement your own big integer type, or use a third party library.

However, I personally would use modular arithmetic.

-- Christopher P. Matthews

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