i wrote a code which calculates the factorials of 1-20. it gives the correct
result until 13 but it is not correct after 13. it even gives negative results.
this is my code
/*faktorial*/
#include<stdio.h>
int main()
{
int x, y, fak;
for(x=1;x<=20;x++){
printf("%d!\t", x);
fak=x;
if(x>=2){
for(y=x;y>=2;y--){
fak=fak*(y-1);
}
}
printf("%d\n", fak);
}
getch();
return 0;
}
why would it be?
best regards..- [c-prog] an example about factorial numbers ruhatadiyaman
- [c-prog] Re: an example about factorial numbers John Matthews
- Re: [c-prog] an example about factorial numbers Rajat Saini
- [c-prog] Re: an example about factorial numbers ruhatadiyaman
- Re: [c-prog] Re: an example about factorial numbers Steve Searle
- [c-prog] Re: an example about factorial numbers ruhatadiyaman
- Re: [c-prog] Re: an example about factorial... Brett McCoy
- Re: [c-prog] Re: an example about factorial... Thomas Hruska
- [c-prog] Re: an example about factorial numbers John Matthews
- [c-prog] Re: an example about factorial numbers John Matthews
- Re: [c-prog] Re: an example about factorial... andrew clarke
