// Rajat Malakar
import java.util.*;
public class Fibonacci {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int prev, next, sum, n = 1, count;
System.out.println("Enter number upto which Fibonacci series to print: ");
count = sc.nextInt();
prev = next = 1;
System.out.println(">>>>>> : Fibonacci Series : <<<<<<");
while (n <= count) {
System.out.println(prev);
sum = prev + next;
prev = next;
next = sum;
n++;
}
}
}
import java.util.*;
public class Fibonacci {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int prev, next, sum, n = 1, count;
System.out.println("Enter number upto which Fibonacci series to print: ");
count = sc.nextInt();
prev = next = 1;
System.out.println(">>>>>> : Fibonacci Series : <<<<<<");
while (n <= count) {
System.out.println(prev);
sum = prev + next;
prev = next;
next = sum;
n++;
}
}
}
Sir,
ReplyDeleteHow to print the same Fibonacci series in reverse order
Sir,
ReplyDeleteHow to print the same Fibonacci series in reverse order
can u dry run this programme
ReplyDeletethnx
ReplyDeleteVery good! Thank you. Happiness.
ReplyDelete