Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
factorial, repeating
#1
1.n = int(input())
2.
3.factorial = 1
4.while n > 1:
5.
6. factorial *= n
7. n -= 1
8.
9.print(factorial)
10.
11.#I would like to write a code where I could repeat the action endlessly and ask the user for the number he wants to find the factorial. I've tried both "break" and "continue", just in the book I'm reading a summary of "while". I also wanted to write "input", but the code did not work
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 734 Dec-12-2023, 09:09 AM
Last Post: buran
  repeating a user_input astral_travel 17 2,335 Oct-26-2022, 04:15 PM
Last Post: astral_travel
  if else repeating Frankduc 12 2,549 Jul-14-2022, 12:40 PM
Last Post: Frankduc
  matching a repeating string Skaperen 2 1,279 Jun-23-2022, 10:34 PM
Last Post: Skaperen
  Random Number Repeating Tzenesh 5 4,080 Jan-13-2021, 10:00 PM
Last Post: deanhystad
  Comparing recursion and loops using two scripts (basic factorial) Drone4four 3 2,281 Oct-11-2020, 06:48 PM
Last Post: deanhystad
  Python factorial code timebrahimy 4 71,726 Sep-27-2020, 12:23 AM
Last Post: timebrahimy
  factorial using recursive function spalisetty06 12 4,129 Aug-25-2020, 03:16 PM
Last Post: spalisetty06
  minor mistake in code for factorial spalisetty06 2 1,908 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,332 Mar-31-2020, 06:40 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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