before you while loop, i would create a variable (call it total for example), and give it a value of 1. then inside the loop, multiply total by the number (x), until (you can use the while loop like you do now) x is one (reduce x by one in each run of the loop

A while loop keeps working as long as the condition is met, in this case x>1.The nature of a factorial is that it multiplies x with x-1,x-2... all the way till 1.4! (Which is the factorial of 4) is 4*3*2*1=24.

First you say: While x > 1, which is good, that works well. When you look inside the loop, you will see that the x never reaches the point where it will reach 1. In your loop, x stays the same. The while is therefore indefinitely valid, and infinite.