Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- static Scanner sc = new Scanner(System.in);
- public static int Fibonacci(int a, int n){
- int b = a+1;
- for (int i = 0; i < n; i++)
- {
- int temp = a;
- a = b;
- b = temp + b;
- }
- return a;
- }
- public static void main(String[] args) {
- int n;
- System.out.println("Podaj liczbę n: ");
- n = sc.nextInt();
- int x;
- System.out.println("Podaj liczbę x: ");
- x = sc.nextInt();
- for (int i = 0; i < n; i++)
- {
- System.out.println(Fibonacci(x,i));
- }
- int y;
- System.out.println("Podaj liczbę y: ");
- y = sc.nextInt();
- for (int i = 0; i < n; i++)
- {
- System.out.println(Fibonacci(y,i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment