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.
Can you tell us which testcase is giving seg fault?
You can just download that testcase and check yourself too.
It must be an edge case or might be using enormous memory.
I get this awesome interesting and unique game which is online and you will love word unscrambler play by using special skills to win this Online Multiplayer game.
Fibonacci Modified
You are viewing a single comment's thread. Return to all comments →
I want to code in c itself. Any way out ?
Yes, Write functions for string multiplication and summation.
how to do that... plz can u explain??
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
i wrote it in c..its giving correct output in devcpp,but here it shows wrong output..
programing with the combination of codes and notes can always help. what is the meaning of the sentence like "a[i]-'0'"?
converting char a[i] to its decimal equivalent
same issue getting correct output in my IDE but segmentation fault while submittin... any suggestion?
Can you tell us which testcase is giving seg fault? You can just download that testcase and check yourself too. It must be an edge case or might be using enormous memory.
I get this awesome interesting and unique game which is online and you will love word unscrambler play by using special skills to win this Online Multiplayer game.
Very easy problem for python users.
Hackerrank - Fibonacci Modified Solution