Advertisement
leomaster

Factorial

Mar 14th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Iteration
  2. f=(n,p=1)=>{ while(n) p*=n--; return p }
  3. //Recursion
  4. f=n=>!n||n*f(~-n)
  5. //Memory
  6. f=n=>[...Array(n)].reduce((s,e,i)=>-~i*s,1)
  7.  
  8.  
  9. main(int i, char **o) <% return o?printf("%d",main(atoi(1[o]),0)):i?i*main(~-i,o):1; %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement