We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
use double to declare data type as double a ,b,c;
while scaning scanf("%lf",&a);
while printing printf("%0.lf",a); // 0.lf restricts the decimal point to zeroth position which is an integer
u have to convert number into array/string, like if number is 543656 then store it in array like |3|4|3|6|5|6|. then write seperate function to add and multiply these array/string and then try to find out fibo.
double will not work.. The no. is too large. If you are doing in Java, there is a datatype for very large no. but in C, you have to take the no. as string and do the addition of two no.s by writing a function for addition of two strings.
Fibonacci Modified
You are viewing a single comment's thread. Return to all comments →
use double to declare data type as double a ,b,c; while scaning scanf("%lf",&a); while printing printf("%0.lf",a); // 0.lf restricts the decimal point to zeroth position which is an integer
thank you.. thanks allloott... :)
Very easy problem for python users.
Hackerrank - Fibonacci Modified Solution
i tried that too. even used long double. that's not working.. can u explain?
in second test case its a 20 digit and crossing number soo long double is not enough to perform tis programme
u have to convert number into array/string, like if number is 543656 then store it in array like |3|4|3|6|5|6|. then write seperate function to add and multiply these array/string and then try to find out fibo.
can u help? what is wrong with this????
void fibonacciModified(double t1, double t2, double n) { int i; double arr[20]; arr[0]=t1; arr[1]=t2; for(i=2;i<20;i++) { arr[i]=t1+t2*t2; t1=t2; t2=arr[i]; } for(i=0;i<20;i++) { if((i+1)==n) printf("%0.lf",arr[i]); } }
double will not work.. The no. is too large. If you are doing in Java, there is a datatype for very large no. but in C, you have to take the no. as string and do the addition of two no.s by writing a function for addition of two strings.
use python or java big integer because double will not work
thanks buddy