#include<stdio.h>
int main()
{
int first=0, second=1, i, n, sum=0;
printf("Enter the number of terms: ");
scanf("%d",&n);
//accepting the terms
printf("Fibonacci Series:");
for(i=0 ; i<n ; i++)
{
if(i <= 1)
{
sum=i;
}
//to print 0 and 1
else
{
sum=first + second;
first=second;
second=sum;
//to calculate the remaining terms.
//value of first and second changes as new term is printed.
}
printf(" %d",sum)
}
return 0;
}
//basic fibonacci series
0, 1, 1, 2, 3, 5, 8, 13, 21, ...
#program to find the fibonacci series
n=int(input('Enter the number of terms in the Fibonacci series :'))
f,s=0,1
print('Fibonacci series =',f,s,sep=',',end=',')
for i in range(3,n+1):
nxt=f+s
print(nxt,end=',')
f,s=s,nxt
#output
Enter the number of terms in the Fibonacci series :7
Fibonacci series =,0,1,1,2,3,5,8,
________________________________________________________________________________
Enter the number of terms in the Fibonacci series :10
Fibonacci series =,0,1,1,2,3,5,8,13,21,34,
________________________________________________________________________________
Enter the number of terms in the Fibonacci series :4
Fibonacci series =,0,1,1,2,
// Fibonacci Series
0,1,1,2,3,5,8,13,21,34,55,89,144......
#fibonacci series is special type of sequence
#fibonacci series is somethinng liket this-->
#0,1,1,2,3,5,8,13,21,34,55,89.......
#addition of former two succesive number results in the third element.
#in simple way as given in above series that 0,1,1--> where 0+1=1 e,i; 1
#example: 2,3,5 addition of 2 and 3 results in latter element in sequence e,i 5
8,13,21 : 8 + 13=21
34,55,89: 34 + 55=89
// FIBONACCI SERIES
// 0 1 1 2 3 5 8 13
let number = 7;
// let a=0,b =1,next;
let a=-1,b=1,next;
for(let i=1;i<=number;i++){
next= a + b;
a = b;
b = next
console.log(next)
}
# Write a program to print fibonacci series upto n terms in python
num = 10
n1, n2 = 0, 1
print("Fibonacci Series:", n1, n2, end=" ")
for i in range(2, num):
n3 = n1 + n2
n1 = n2
n2 = n3
print(n3, end=" ")
print()