Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class fibo {
- static int a = 0, b = 1, s = 0, n = 0;
- public static void main(String[] args) {
- Scanner sc =15 new Scanner(System.in);
- System.out.println("enter what position number you want from fibonaci series");
- n = sc.nextInt() - 2;
- int p = loops(0, 1);
- System.out.println(p);
- }
- public static int loops(int x, int y) {
- if (n != 0) {
- s = x + y;
- n -= 1;
- return loops(y, s);
- } else {
- return s;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment