Advertisement
kishi5

Untitled

Oct 9th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import java.util.*;
  2. public class tatatz {
  3.  
  4. public static void main(String[] args) {
  5. Scanner ler = new Scanner(System.in);
  6. System.out.print("Infomre o valor de N: ");
  7. int n = ler.nextInt();
  8. fibonacci(n);
  9. System.out.printf("O N'esimo numero é: %d", fibonacci(n));
  10. }
  11. public static int fibonacci (int x){
  12. int a = 1,b = 0;
  13. for(int i = 1;i < x; i++){
  14. a = a + b;
  15. b = a - b;
  16.  
  17.  
  18. }
  19. return a;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement