Computer Science, asked by kundunilay89, 5 months ago

Write a program to find the sum of 1st 10 numbers of Fibonacci series i.e. 1,1,2,3,5,8,13….
Fibonacci series is such a series which starting from 1 and 1, and subsequent numbers are the
sum of the previous two numbers.

Answers

Answered by roshan211220
1

Answer:

this is for phython.

Explanation:

# 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

Answered by duragpalsingh
1

Question:

Write a program to find the sum of 1st 10 numbers of Fibonacci series, i.e. 1,1,2,3,5,8,13…. Fibonacci series is such a series which starting from 1 and 1, and subsequent numbers are the sum of the previous two numbers.

Solution:

Language used: Java

public class FibSum

{

static void main()

{

int i,a=1,b=0,c;

System.out.println("Fibonacci series =");

for(i=1;i<=10;i++)

{

c=a+b;

System.out.print(c+" ");

a=b;

b=c;

}

}

}

Similar questions