answersLogoWhite

0

In a Fibonacci sequence, the previous two numbers are added to generate the next Fibonacci number.

F1=1st number

F2=2nd number

F3=f1+f2=1+2=3

F4=f2+f3=2+3=5

F5=f3+f4=3+5=8, and so on.

f1 f2 f3 f4 f5 f6 f7..............

1 2 3 5 8 13 21.............

In algorithm:

1. Assign sum=0, A=0, B=1, i=1

2. Get the no. of terms upto which u want to generate the Fibonacci no, i.e., n.

3.Add A and B to get the next Fibonacci number

4. Assign the value of B to A i.e. A=B

5. Assign the value of sum to B i.e. B=sum

6. Write the value of su to get next Fibonacci number in the series.

7. increment i with 1 i.e. i=i+1 and repeat step 3,4,5,6 with the last value of i=n(n is the no. of terms which u wnt to generate Fibonacci no. series.)

8. Stop

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
JudyJudy
Simplicity is my specialty.
Chat with Judy
More answers

the fibbonacci series is defined as each member is the sum of the last 2 members, satrting with 1,1.

prev = 0

curr = 1

startLogic

display curr

next = prev + curr

prev = curr

curr = next

goto startLogic

will output the fibbonacci series.

User Avatar

Wiki User

16y ago
User Avatar

WRITE 'Input the limit'

READ N

FOR i = 1 TO N DO

IF (i = 1)

F1 = 1

WRITE (F1)

ELSE IF (i = 2)

F2 = 1

WRITE (F2)

ELSE

F3 = F1 + F2

WRITE (F3)

F1 = F2

F2 = F3

END IF-ELSE

END FOR

User Avatar

Wiki User

12y ago
User Avatar

1.start

2.a=0,b=1,c and counter

3.display a

4.display b

5.c=a+b

6.display c

7.a=b

8.b=c

9.check whether number is less than the last number you have

if yes than go to step 5

if no stop it

User Avatar

Wiki User

14y ago
User Avatar

1.start

2.a=0,b=1,c and counter

3.display a

4.display b

5.c=a+b

6.display c

7.a=b

8.b=c

9.check whether number is less than the last number you have

if yes than go to step 5

if no stop it

Read more: Draw_a_flow_chart_that_displays_the_Fibonacci_series

User Avatar

Wiki User

13y ago
User Avatar

///////////////////////////////

In psuedocode:

///////////////////////////////

prevnum = 0;

num = 1;

while not done {

print num

num += prevnum

prevnum = num - prevnum

}

/****** in C: ******/

#include <stdio.h>

#define SEQUENCE_LENGTH 10

int main( int argc, char *argv[] ){

int prevnum = 0, n;

int num = 1;

for(n = 0; n < SEQUENCE_LENGTH; n++){

printf("%i ", num);

num += prevnum;

prevnum = num - prevnum;

}

return 0;

}

User Avatar

Wiki User

15y ago
User Avatar

Nk = Nk-1 + Nk-2

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write an algorithm for fibonic number?
Write your answer...
Submit
Still have questions?
magnify glass
imp