java program to find first 7 terms of fibonnaci series
class fibo
{
public static void main(String args[])
{
int a=1,b=1,c=0;
System.out.print("\n\n\t\t===============================");
System.out.print("\n\n\t\tFirst 7 terms of Fibonacci series are ");
System.out.print("\n\n\t\t===============================");
System.out.print("\n\n\t\t"+a+" "+b);
for(int i=3;i<=7;i++)
{
c=a+b;
System.out.print(" "+c);
a=b;
b=c;
}
System.out.print("\n\n\t\t===============================");
}
}
OUTPUT : -
No comments:
Post a Comment