assigments
This commit is contained in:
21
assignments/assignment1/fibonacci.java
Normal file
21
assignments/assignment1/fibonacci.java
Normal file
@ -0,0 +1,21 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class fibonacci {
|
||||
public static void main(String args[]) {
|
||||
int a = 0;
|
||||
int b = 1;
|
||||
int count = 1;
|
||||
int userInput;
|
||||
Scanner scan = new Scanner(System.in);
|
||||
System.out.println("Enter positive number!");
|
||||
userInput = scan.nextInt();
|
||||
|
||||
while (userInput >= b) {
|
||||
int c = a + b;
|
||||
a = b;
|
||||
b = c;
|
||||
++count;
|
||||
}
|
||||
System.out.println("Index is : "+count);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user