assigments

This commit is contained in:
2024-10-21 20:18:52 +03:00
parent 36c0d2e1b1
commit 8928b8471a
3 changed files with 51 additions and 0 deletions

View 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);
}
}