Skip to content

Instantly share code, notes, and snippets.

@jorarmarfin
Created July 11, 2024 01:19
Show Gist options
  • Save jorarmarfin/0b161614783f7aa56aa0a6be178d230f to your computer and use it in GitHub Desktop.
Save jorarmarfin/0b161614783f7aa56aa0a6be178d230f to your computer and use it in GitHub Desktop.
factorial(0,1).
factorial(N,R):- N>0,N1 is N-1 , factorial(N1,R1), R is N*R1.
fibonacci(0,1).
fibonacci(2,1).
fibonacci(N,R):- N>2,N1 is N-1, N2 is N-2,fibonacci(N1,R1),fibonacci(N2,R2), R is R1+R2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment