Advertisement
exmkg

Untitled

Aug 23rd, 2024
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.19 KB | None | 0 0
  1. class Solution {
  2.     public int fib(int n) {
  3.         // https://visualgo.net/en/recursion
  4.         if (n <= 1) {
  5.             return n;
  6.         }
  7.         return fib(n - 1) + fib(n - 2);
  8.     }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement