Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Find Factors of a Number using While Loop with validation

print("Enter a Number: ", end="")
try:
    num = int(input())

    print("
Factors of " +str(num)+ " are: ", end="")
    i = 1
    while i<=num:
        if num % i == 0:
            print(i, end=" ")
        i = i + 1
    print()
except ValueError:
    print("
Invalid Input!")
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Find #Factors #Number #While #Loop #validation
ADD COMMENT
Topic
Name
8+4 =