Reputation: 471
I am just trying to do a problem in C that may give us 64 bit integers. It cannot support in displaying such big number. So what can i do?
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
long int a,b,n,c;
scanf("%ld %ld %ld",&a,&b,&n);
n-=2;
while(n--){
c=(b*b)+a;
a=b;
b=c;
}
printf("%ld",c);
return 0;
}
Upvotes: 0
Views: 108
Reputation: 343
You should use %lld
.
scanf("%lld %lld %lld",&a,&b,&n);
printf("%lld",c);
But long int
is not an 64bit integer. Use long long int
or int64_t
from inttypes.h
.
Upvotes: 2