Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class fibNumber {
- public void nextFib(int[] num)
- {
- fibNumber test = new fibNumber();
- for(int i = 0; i < num.length; i++)
- {
- int j = 1;
- while(true)
- {
- if(test.fibonacciNumber(j) > num[i])
- {
- System.out.println(test.fibonacciNumber(j));
- break;
- }
- j++;
- }
- }
- }
- public int fibonacciNumber(int n)
- {
- if(n == 1)
- return 1;
- else if(n == 2)
- return 1;
- else
- return fibonacciNumber(n - 1) + fibonacciNumber(n - 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement