Computer Science, asked by rahulmulik, 8 months ago

12. Write a function to print Fibonacci serie​

Answers

Answered by ANUSHKA0809
2

int main() { int n, first = 0, second = 1, next, c;

printf("Enter the number of terms\n"); scanf("%d", &n);

printf("First %d terms of Fibonacci series are:\n", n);

for (c = 0; c < n; c++) { if (c <= 1) next = c; else. { next = first + second; first = second; second = next; } ...

return 0; }

HOPE YOU LIKE THE ANSWER...

Answered by DarksiderOp
3

Explanation:

Source Code

# Program to display the Fibonacci sequence up to n-th term

nterms = int(input("How many terms? "))

# first two terms

n1, n2 = 0, 1

count = 0

# check if the number of terms is valid

if nterms <= 0:

print("Please enter a positive integer")

elif nterms == 1:

print("Fibonacci sequence upto",nterms,":")

print(n1)

else:

print("Fibonacci sequence:")

while count < nterms:

print(n1)

nth = n1 + n2

# update values

n1 = n2

n2 = nth

count += 1

Output

How many terms? 7

Fibonacci sequence:

0

1

1

2

3

5

8

plz mark it as brainlist answere and thank my answer

Similar questions