Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class tatatz {
- public static void main(String[] args) {
- Scanner ler = new Scanner(System.in);
- System.out.print("Infomre o valor de N: ");
- int n = ler.nextInt();
- fibonacci(n);
- System.out.printf("O N'esimo numero é: %d", fibonacci(n));
- }
- public static int fibonacci (int x){
- int a = 1,b = 0;
- for(int i = 1;i < x; i++){
- a = a + b;
- b = a - b;
- }
- return a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement