Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. //1 1 2 3 5 8
  2. //числа фибоначчи
  3.  
  4. public class lesson1712 {
  5.  
  6. public static int fib(int n){
  7. if (n == 1 || n == 2) {
  8. return 1;
  9. }
  10. return (fib(n-1) + fib(n-2));
  11. }
  12.  
  13. public static void main(String[] args){
  14. System.out.println(fib(6));
  15.  
  16.  
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement