Skip to main content

Matlab, 15

f=@(x)prod(1:x)

Test Cases

>> f(0)
ans =
     1
>> f(4)
ans =
    24
>> tic,f(125),toc
ans =
  1.8827e+209
Elapsed time is 0.000380 seconds.
Jonas
  • 379
  • 1
  • 7