Comments on: Checking if a number is fibonacci https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/ Coding / System Design Interviews Fri, 11 Nov 2022 09:11:52 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: ss https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-6970 Fri, 11 Nov 2022 09:11:52 +0000 http://www.ritambhara.in/?p=177#comment-6970 yes

]]>
By: gaurav https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-6196 Mon, 27 Dec 2021 07:12:41 +0000 http://www.ritambhara.in/?p=177#comment-6196 smoothly explained.

]]>
By: gaurav https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-6195 Mon, 27 Dec 2021 07:10:40 +0000 http://www.ritambhara.in/?p=177#comment-6195 In reply to vishal.

int Fibonacci(int a)
{
if (a==0) return 0;
else if(a==1)
return 1;
else
return ( Fibonacci(a-1)+ Fibonacci(a-2));
}
visit: https://studyfame.com/c-program/fibonacci-series-program-in-c-using-recursion

]]>
By: vishal https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-6194 Mon, 27 Dec 2021 07:06:11 +0000 http://www.ritambhara.in/?p=177#comment-6194 how can I do this with recursion

]]>
By: Havillaj https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-6097 Sat, 06 Nov 2021 20:08:41 +0000 http://www.ritambhara.in/?p=177#comment-6097 In reply to Shaan007.

What are the names of your files

]]>
By: ur mum https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-6025 Mon, 11 Oct 2021 09:55:23 +0000 http://www.ritambhara.in/?p=177#comment-6025 In reply to Nguyễn Thanh Trọng.

No u!

]]>
By: Sunil Chaudhari https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-4606 Thu, 24 Sep 2020 13:43:30 +0000 http://www.ritambhara.in/?p=177#comment-4606 In reply to muhammad.

Change the condition for the while loop
Replace < by <=

It will give correct output.

]]>
By: Shaan007 https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-4592 Sun, 20 Sep 2020 14:49:22 +0000 http://www.ritambhara.in/?p=177#comment-4592 This will 100% work. And it’s compact as well…
#include
#include
#include
int main()
{
int n,calc1,calc2,pwr;
printf(“Enter a number : “);
scanf(“%d”,&n);
pwr= pow(n,2)+0.5;
calc1=(5*pwr)+4;
calc2=(5*pwr)-4;
if(sqrt(calc1)==round(sqrt(calc1)) || sqrt(calc2)==round(sqrt(calc2)))
{
printf(“The number is Fibonacci”);
}
else
{
printf(“The number is not Fibonacci”);
}
getch();
return(0);
}

]]>
By: Nguyễn Thanh Trọng https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-4413 Wed, 24 Jun 2020 08:26:22 +0000 http://www.ritambhara.in/?p=177#comment-4413 In reply to Yash.

you are stupid! you can use function pow (n,2) in include

]]>
By: Yash https://demo.ritambhara.in/checking-if-a-number-is-fibonacci/#comment-4033 Tue, 21 Apr 2020 10:11:08 +0000 http://www.ritambhara.in/?p=177#comment-4033 In reply to muhammad.

Maybe you are calculating 5*n^2+4 in the code, but in c,c++ it should be 5*n*n-4.

]]>