answersLogoWhite

0


Best Answer

In a Fibonacci sequence, sum of two successive terms gives the third term....

here is the Fibonacci sequence:

0,1,1,2,3,5,8,13,21,34,55,89,144........

General formula to generate a Fibonacci sequence is """Fn= Fn-1 + Fn-2"""

To check whether a number is Fibonacci or not follow the following steps:

1) Get the number as input from user.

2) Fix the first two numbers of sequence as 0 and 1.

3) put a sentinel loop with upper limit being the input number.

4)in the body of loop generate the next number in sequence in each iteration and continue swapping the values as follows:

a=0

b=1

next=a+b

while (next< input)

a=b

b=next

next=a+b wend

5) lastly when program exits the loop compare the last number of sequence with the input number

if they are equal then number is Fibonacci otherwise not.

otherwise the last term of sequence will be less than the input number.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you check whether a given number n is a Fibonacci number or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you draw a Flowchart to find whether the given number is odd or even using counter?

first we write start and then read number and after that check the number is totaly divide by 2 or not if number is totally divide by 2 then number is even else number is odd.


Write a c programme to check whether given number is Fibonacci?

#include&lt;iostream.h&gt; #include&lt;conio.h&gt; void main() { long int n,a=0,b=1; cout&lt;&lt;"dear user Enter number as u wish"; cin&gt;&gt;n; while(n&gt;0) { c=a+b; cout&lt;&lt;"c&lt;&lt;"\t\t"; a=b; b=c; } getch(); }


How do you find whether a given number is even or odd in Unix shell programming?

echo "Program to check even or odd number"echo "Enter a number"read na=`expr $n % 2`if [ $a -eq 0 ] ; then #Semicolon is most important for Executing ifelse statementsecho "It is an even number"elseecho "It is an odd number"fi


Write an algorithm and draw a corresponding flowchart to find the greatest number and its position among the 6 given numbers?

Algorithm Step1: Read A, B, C Step2: If A &gt; B is True, then check whether A &gt; C, if yes then A is greatest otherwise C is greatest Step3: If A &gt; B is False, then check whether B &gt; C, if yes then B is greatest otherwise C is greatest Give the Flowchart Answer


Write a java program to generate the Fibonacci Series using for loop?

class Fibonacci { public static void main(String args[]) { System.out.println("enter the number upto u want"); int number=Integer.parseInt(args[0]); int a=0,b=1,c=0; System.out.print(a+" "+b); for(int i=1;i&lt;=number;i++) { c=a+b; System.out.print(c+" "); a=b; b=c; } } } the number are given to the run time where are print the series eg: 5 0 1 1 2 3 5 8 13................

Related questions

To check whether the given number is an Avogadro number or not?

45


What name is given to this sequence 11235813?

It is called a Fibonacci number sequence! 1,1,2,3,5,8,13,21...


Write an algorithm to check whether the given number is odd or even?

Type your answer here... i think we should first enter 1 number then check it


Draw a flow chart to check whether a given number is prime or not?

[object Object]


Could you write a assembly language program in tasm To check whether a given number present in a sequence of given memory location containing the string to be checked in 8086?

8086 assembly language program to check wether given number is perfect or not


Write a shell programs for to check whether the given number is an Avogadro number or not?

Avogadro's number is a constant. Therefore only one number is equal to Avogadro's number.


Lab manual in mca 1st sem from ignou?

write a program in C to check whether a given number is apalindrome or not


What is the special name given to this number pattern 1 1 2 3 5 8 13?

The Fibonacci sequence.


What was Fibonacci's famous mathematical invention?

Fibonacci is most famous for his description of the number sequence, which in the 19th century was given the name 'Fibonacci numbers' . The sequence is made by starting with two ones, and adding them up, then to make every new term, the previous two terms need to be added together.


To check whether the given number is even or odd?

Is the last digit 2, 4, 6, 8 or 0? If yes, it's even, else odd.


What is the first positive non-Fibonacci number?

4 Fibanocci numbers are each the sum of the 2 previous numbers, i.e. 1,1,2,3,5,8 Thus 4 is the first one missing By modern definition, the above response is incorrect - 0 (zero) is both positive (it is defined as such) and not in the Fibonacci set. This answer is given based on a slight assumption, there cannot be a "first number" on a number line. The lowest number that is positive and not within the set of Fibonacci numbers (as inferred as the true meaning of your question) is zero.


To check whether given number is a prime number or not?

See whether the number is divisible by 2, and by all odd numbers up to the square root of the number. For numbers up to 100, it is enough to check the factors 2, 3, 5, and 7. For higher numbers you need to check more factors. For very large numbers (for example, hundreds of digits), more efficient methods are known, but those methods are also more complicated.