x = 1
while x <= 50:
x*=1
These statements are resulting in an infinite loop since multiplying x
by one will never change it. Mathematically, x * 1 -> x
.
In addition, if you're trying to multiply the numbers one through fifty, you don't want this:
total = 0
for some condition:
total = total * something
since total
will forever remain at zero. Mathematically, x * 0 -> 0
.
The correct pseudo-code (which looks remarkably like Python) for getting the product of the numbers one through fifty is:
product = 1
for number = 1 through 50 inclusive:
product = product * number
Changing your code to match that requires two things:
total
should start at one.- you should add one to
x
in the loop rather than multiplying.