How to use the while loop to get the factorial of an integer without getting endless factorials back?
<p>I have to write a program that tells the user the factorial of any integer between 1 and 15 while using the while loop. I wrote the code below and the output gives me endless factorials/numbers.. Do you know what I did wrong? Thank you!</p>

<p>Update: I realized that I should use "while" for what num isn't, so I now have this code below, but it still says invalid syntax for the second "while".</p>

<pre><code># take input from the user
num = int(input("Please enter a number from 1 to 15: "))
factorial = 1

# check if the number is negative, positive or zero
while num &lt; 0:
   num = int(input("Negative numbers don't have factorials! Please enter a number between 1 and 15: ")
while num &gt; 15:
   num = int(input("Please enter a number between 1 and 15! ")
if num == 0:
   print("The factorial of 0 is 1")
else:
   for i in range(1,num + 1):
       factorial = factorial*i
   print("The factorial of",num,"is",factorial)
</code></pre>