#include
int main()
{
int a=0;
int b=1;
int c=0;
int n,i;
printf(“enter n value”);
scanf(“%d”,&n);
printf(“%d%d”,a,b);
while(i<=n)
{
c=a+b;
printf("%d",c);
a=b;
b=c;
i++;
}
return 0;
}
it will print the fibo series
import java.util.*;
public class Fibonacci{
static int fibo(int f){
if(f<=1){
return f;
}
else{
return fibo(f-1)+fibo(f-2);
}
}
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("enter the number to print fibo series :");
int n=sc.nextInt();
for(int i=0;i<n;i++){
System.out.println(fibo(i));
}
num = int(input(“enter num ::”))
a= 0;b= 1
print(a,end=” “)
while(not(b > num+1)):
print(b,end= ” “)
temp = a+b
a= b
b = temp
in Python
n=int(input(“Enter the number”))
first=0
second=1
for i in range(n):
print(first)
temp=first
first=second
second=temp+second
#include
int main()
{
int a=0;
int b=1;
int c=0;
int n,i;
printf(“enter n value”);
scanf(“%d”,&n);
printf(“%d%d”,a,b);
while(i<=n)
{
c=a+b;
printf("%d",c);
a=b;
b=c;
i++;
}
return 0;
}
IN Python
def fibonacci(n):
if(n<0):
print(false)
if(n==0):
return 0
if(n==0):
return 1
else:
return(fibonacci(n-2)+fibonacci(n-1)
fibonacci(9)
if(fibonacci(n)):
print("fibonacci of",n,'is':fibonacci(n))
else:
print("Error")
it will print the fibo series
import java.util.*;
public class Fibonacci{
static int fibo(int f){
if(f<=1){
return f;
}
else{
return fibo(f-1)+fibo(f-2);
}
}
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("enter the number to print fibo series :");
int n=sc.nextInt();
for(int i=0;i<n;i++){
System.out.println(fibo(i));
}
}
}
0 is not a fibonacci number at all
printf statement must be after t2=next term
printf(“%d”,t1)