#builtIn and #iterative way of factorial

in builtin •  7 years ago  (edited)

#built way of factorial 

from math import factorial# imports is like a libraries in java and c++ 

print "built in way"

print(factorial(10))

#iterative  way

fac=1

for x in range(1,11):

  fac=fac*x

print ("iterative way")

print (fac) 

#result

built in way
3628800
iterative way
3628800
   

 


   


Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!