Udemy coupon 100 off 2017 ::Udemy coupon code free :: Get 100+ Free Udemy coupons Here

Fibonacci Series using Java.

Fibonacci Series using Java.


Out Put is as following :

class FibonacciSeries
{
public static void main(String args[])
{
int PrevNum, NextNum, Sum, i;
PrevNum=NextNum=1;
System.out.println();
for(i=1;i<=10;i++)
{
System.out.print(PrevNum+"       ");
Sum=PrevNum+NextNum;
PrevNum=NextNum;
NextNum=Sum;
}
}
}




  • Save the file with name FibonacciSeries.java 
  • Compile with: javac FibonacciSeries.java
  • Run with: java FibonacciSeries


No comments:

Post a Comment