i trying problem in c may give 64 bit integers. cannot support in displaying such big number. can do?
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> int main() { /* enter code here. read input stdin. print output 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; }
you should use %lld.
scanf("%lld %lld %lld",&a,&b,&n); printf("%lld",c); but long int not 64bit integer. use long long int or int64_t inttypes.h.
Comments
Post a Comment