##### factorial, repeating
 factorial, repeating Aldiyar Unladen Swallow Posts: 1 Threads: 1 Joined: Aug 2020 Reputation: Aug-22-2020, 05:52 PM (This post was last modified: Aug-22-2020, 07:57 PM by Gribouillis.) 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 Posts: 4,675 Threads: 73 Joined: Jan 2018 Reputation: Aug-22-2020, 07:56 PM You can repeat endlessly with a `while True` loop ```while True: # code to be repeated endlessly``` Reply hussainmujtaba Silly Frenchman Posts: 43 Threads: 0 Joined: Apr 2020 Reputation: Sep-01-2020, 02:47 PM (This post was last modified: Sep-22-2020, 06:48 AM by buran.) I dont get the question completely but i gues this would help```def iter_factorial(n): factorial=1 n = input("Enter a number: ") factorial = 1 if int(n) >= 1: for i in range (1,int(n)+1): factorial = factorial * i return factorial num=int(input("Enter the number: ")) print("factorial of ",num," (iterative): ",end="") print(iter_factorial(num))```If this does not help, try to go through this article factorial in python Reply Posts: 6,533 Threads: 19 Joined: Feb 2020 Reputation: Sep-01-2020, 03:09 PM 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 DPaul Verb Conjugator Posts: 739 Threads: 120 Joined: Dec 2017 Reputation: Sep-01-2020, 05:22 PM I hate to spoil the party: ```import math print(math.factorial(3))```Paul It is more important to do the right thing, than to do the thing right.(P.Drucker) Better is the enemy of good. (Montesquieu) = French version for 'kiss'. Reply

 Possibly Related Threads… Thread Author Replies Views Last Post Why is 2/3 not just .666 repeating? DocFro 4 1,112 Dec-12-2023, 09:09 AM Last Post: buran repeating a user_input astral_travel 17 3,164 Oct-26-2022, 04:15 PM Last Post: astral_travel if else repeating Frankduc 12 3,310 Jul-14-2022, 12:40 PM Last Post: Frankduc Comparing recursion and loops using two scripts (basic factorial) Drone4four 3 2,585 Oct-11-2020, 06:48 PM Last Post: deanhystad Python factorial code timebrahimy 4 90,284 Sep-27-2020, 12:23 AM Last Post: timebrahimy factorial using recursive function spalisetty06 12 4,807 Aug-25-2020, 03:16 PM Last Post: spalisetty06 minor mistake in code for factorial spalisetty06 2 2,216 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,639 Mar-31-2020, 06:40 PM Last Post: deanhystad Want to print each iteration of factorial program sbabu 10 5,153 Jan-09-2020, 07:25 AM Last Post: perfringo Factorial sketch(python 3) KingArthur526 1 2,202 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