Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
Python
C
Java
def F(n): if n <= 1: return n else: return F(n - 1) + F(n - 2) print(F(19)) #Python
#include
int F(int n) { if (n <= 1) { return n; } else { return F(n - 1) + F(n - 2); } } int main() { printf("%d\n", F(19)); return 0; } //C
public class Main { public static int F(int n) { if (n <= 1) { return n; } else { return F(n - 1) + F(n - 2); } } public static void main(String[] args) { System.out.println(F(19)); } } //Java
Python result:
C result:
Java result:
4181
4181
4181