Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- static Scanner sc = new Scanner(System.in);
- public static void Fibonacci(int x, int y, int n){
- int b = x+1;
- System.out.println(n + " kolejnych liczb ciągu Fibonacciego od liczby x = " + x);
- for (int i = 0; i < n; i++)
- {
- int temp = x;
- x = b;
- b = temp + b;
- System.out.println(x);
- }
- int a = y+1;
- System.out.println(n + " kolejnych liczb ciągu Fibonacciego od liczby y = " + y);
- for (int i = 0; i < n; i++)
- {
- int temp = y;
- y= a;
- a = temp + a;
- System.out.println(y);
- }
- }
- 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();
- int y;
- System.out.println("Podaj liczbę y: ");
- y = sc.nextInt();
- Fibonacci(x,y,n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment