Python Forum
computing the factorial of N
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
computing the factorial of N
#10
(Aug-01-2017, 08:08 PM)nilamo Wrote: This is two months old, so sure, let's throw answers around.

import functools

fact = int(input("What number to factorial? "))
print(functools.reduce(lambda x, y: x*y, range(1, fact+1)))

Although I have no idea what that means, it looks very cool and is probably the fastest way to find out the factorial of N Smile
Reply


Messages In This Thread
computing the factorial of N - by foolsgold27 - Jun-01-2017, 02:19 PM
RE: HELP SOLVING SIMPLE PYTHON PROBLEM - by Turry - Jun-01-2017, 03:54 PM
RE: HELP SOLVING SIMPLE PYTHON PROBLEM - by prog92 - Jun-01-2017, 05:56 PM
RE: HELP SOLVING SIMPLE PYTHON PROBLEM - by nilamo - Jun-01-2017, 07:06 PM
RE: HELP SOLVING SIMPLE PYTHON PROBLEM - by wavic - Jun-02-2017, 06:36 AM
RE: HELP SOLVING SIMPLE PYTHON PROBLEM - by wavic - Jun-02-2017, 08:27 AM
RE: computing the factorial of N - by martan45 - Aug-01-2017, 07:58 PM
RE: computing the factorial of N - by nilamo - Aug-01-2017, 08:08 PM
RE: computing the factorial of N - by martan45 - Aug-01-2017, 08:16 PM
RE: computing the factorial of N - by nilamo - Aug-01-2017, 08:30 PM
RE: computing the factorial of N - by ichabod801 - Aug-02-2017, 02:16 AM
RE: computing the factorial of N - by nilamo - Aug-02-2017, 02:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Program to Find the Factorial of a Number elisahill 2 1,493 Nov-21-2022, 02:25 PM
Last Post: DeaD_EyE
  computing average in nested loops cap510 5 5,248 Sep-11-2020, 12:33 PM
Last Post: deanhystad
  Fork the process (factorial) vndywarhol 3 3,444 Sep-07-2018, 03:28 AM
Last Post: ichabod801
  Computing average vestkok 2 2,552 Aug-12-2018, 10:02 AM
Last Post: vestkok
  Computing factorials Truman 6 4,162 Mar-14-2018, 06:38 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020