Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. function factAcc(n,acc,k) {
  2. if n > 1
  3. then factAcc(n-1, acc*n, k)
  4. else k(acc)
  5. }
  6.  
  7. function factorial(n,k) {
  8. factAcc(n,1,k);
  9. }
  10.  
  11. function main(k) {
  12. n = read()
  13. factorial(n, main2(_,k));
  14. }
  15.  
  16. function main2(a, k) {
  17. print(a)
  18. k()
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement