You're running into problems because the datatype int you're using is 32 bits and can only hold values up to 2^31-1 = 2147483647 when signed (default, 31 bits used, 1 bit is occupied to indicate signedness this also explains the negative numbers), 2^32-1 = 4294967295 when unsigned You can use a 64 bit datatype here ( long long in most cases), but will also run in problems with this one later (around the 94th fibonacci number, I think).
You're running into problems because the datatype int you're using is 32 bits and can only hold values up to 2^31-1 = 2147483647 when signed (default, 31 bits used, 1 bit is occupied to indicate signedness, this also explains the negative numbers), 2^32-1 = 4294967295 when unsigned. You can use a 64 bit datatype here (long long in most cases), but will also run in problems with this one later (around the 94th fibonacci number, I think). The "real" solution to this problem is to write your own methods for numerical calculations and use an own representation of the numbers, f.e.An array of chars.
You can also look for one of the various possibilites to use a "bignum" library. You should find more information about this in some SO questions, for example this one.
4 Also, it's preferable to use unsigned types for things that can't be negativ. – Xeo Mar 31 at 17:08 Btw, consider adding the exact cause of the negative representation to your answer, that makes it more complete. – Xeo Mar 31 at 17:15 @Xeo Not according to most experts.
Unsigned is generally understood to mean that bit manipulations or modula arithmetic are required. – James Kanze Mar 31 at 17:18.
Declaring your variable as unsigned int will allow you to do a bit more interactions, but you'll run into problems anyway. Extending the size of your variable, using a long long int will still delay your problem. You can't solve this because, sooner or later, you will exceed the maximum number you can represent, whatever data-type you'll choose.
Or you'll run out of memory. Some implementations of BigInt will allow "infinite" precision, but in the end, "infinite" is never larger than the amount of available memory. – James Kanze Mar 31 at 17:19.
Ints only hold 32 bits of data, for a maximum value of 2,147,483,647. Your return values are "overflowing". Use the ulong data type, which holds 64 bits and has a max value of 18,446,744,073,709,551,615.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.