Advertisement
Guest User

Untitled

a guest
Jan 14th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.37 KB | None | 0 0
  1. stirling(N, M, X) :- N < M, X is 0.
  2. stirling(N, N, 1).
  3. stirling(N, 1, 1).
  4. stirling(N, 0, 0) :- N > 0.
  5. stirling(N, M, X) :- N > M, I is N-1, J is M-1, stirling(I, J, K), stirling(I, M, L), X is K + M * L.
  6. petla(N, N, X) :- stirling(N, N, K), X is K.
  7. petla(N, I, X) :- I < N, K is I+1, stirling(N, I, J), petla(N, K, L), X is J + L.
  8. bell(N, X) :- petla(N, 0, K), X is K.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement