#include<iostream>
#include<new>
usingnamespace std;
int main()
{
intunsigned n,i,*sc;
cout << "enter how many numbers you want: \n";
cin >> i;
sc=newintunsigned [i];
*sc=0;*(sc+1)=1;
for (n=2;n<i;n++)
{
*(sc+n)=*(sc+(n-2))+*(sc+(n-1));
cout << *(sc+n) << "\n";
}
system("pause");
return 0;
}
Everything goes perfectly fine, but after some values, the numbers start going out wrong... I think it's because the last sane value passes the limit of the long int values...which is 4294967295 (unsigned). If that is really my problem, is there any possible way to overcome it? If that isn't the problem, then what is it?
Nowadays, with the new standard, compilers *have* to accept it. Thank goodness.
The bounds of a signed long long int are −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. The bounds of an unsigned long long int are 0 to somewhere around 1.844674407×1019. I hope that'll be enough space. ;)
wow, really? 9,223,372,036,854,775,807, signed?? That's REALLY a lot... the last normal number i get is 12,200,160,415,121,876,738 (unsigned), but i dont think i need more than that :P
edit: O.o that sounds like a real badass library xD too bad I don't know how to install 3rd party libraries... I started programming on c++ (for real) like a month ago, so I don't know much. I just made this program for fun, (I didn't even have fibonacci at school yet :P) so it doesn't really have to be unlimited,but it'd be really cool...