Advertisement
Katerina10092018

Untitled

Feb 26th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class funcs {
  4. static Scanner scanner = new Scanner(System.in);
  5.  
  6. static int fibonachchi(int x) {
  7. int r = 1;
  8. int a = 0;
  9. int b = 1;
  10. for (int i = 1; i < x; i++) {
  11. r = a+b;
  12. a=b;
  13. b=r;
  14.  
  15. }
  16. return r;
  17. }
  18. public static void main(String[] args) {
  19. System.out.println("Введите число ");
  20. int n = scanner.nextInt();
  21. int j;
  22. j = fibonachchi(n);
  23.  
  24. System.out.println(j);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement