Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
factorial, repeating
#4
I believe all is asked for is wrapping a loop around the loop. To elaborate slightly on Gribouillis:
while True:
    try:
        n = int(input('Enter number or done: '))
    except ValueError:
        break  # Quit if input is not a number

    factorial = 1
    for i in range(1, n+1):
        factorial *= i
    print(f'{n}! = {factorial}')
Reply


Messages In This Thread
factorial, repeating - by Aldiyar - Aug-22-2020, 05:52 PM
RE: factorial, repeating - by Gribouillis - Aug-22-2020, 07:56 PM
RE: factorial, repeating - by hussainmujtaba - Sep-01-2020, 02:47 PM
RE: factorial, repeating - by deanhystad - Sep-01-2020, 03:09 PM
RE: factorial, repeating - by DPaul - Sep-01-2020, 05:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is 2/3 not just .666 repeating? DocFro 4 793 Dec-12-2023, 09:09 AM
Last Post: buran
  repeating a user_input astral_travel 17 2,435 Oct-26-2022, 04:15 PM
Last Post: astral_travel
  if else repeating Frankduc 12 2,660 Jul-14-2022, 12:40 PM
Last Post: Frankduc
  Comparing recursion and loops using two scripts (basic factorial) Drone4four 3 2,303 Oct-11-2020, 06:48 PM
Last Post: deanhystad
  Python factorial code timebrahimy 4 77,021 Sep-27-2020, 12:23 AM
Last Post: timebrahimy
  factorial using recursive function spalisetty06 12 4,197 Aug-25-2020, 03:16 PM
Last Post: spalisetty06
  minor mistake in code for factorial spalisetty06 2 1,944 Aug-22-2020, 05:00 PM
Last Post: spalisetty06
  Factorial Code is not working when the given number is very long integer Raj_Kumar 2 2,370 Mar-31-2020, 06:40 PM
Last Post: deanhystad
  Want to print each iteration of factorial program sbabu 10 4,667 Jan-09-2020, 07:25 AM
Last Post: perfringo
  Factorial sketch(python 3) KingArthur526 1 2,009 Sep-25-2019, 01:51 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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