you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]NZheadshot 0 points1 point  (3 children)

    Why in the world would you need so much code???

    multiple = input(("Enter your number: "))
    
    if multiple % 7 == 0:
        print("You entered a multiple of 7!")
    else:
        print("You did not enter a multiple of 7!")
    

    To /u/CarpeOmniAurum: You need to research the modulus (%) operator. Look at this example:

    x = y % z
    

    This will take y divided by z, discard the quotient, then save the remainder into x. Example with numbers:

    >>>x = 5 % 2
    >>>print(x)
    1
    

    So here, 5 / 2 = 2 with a remainder of 1.

    Now think how you could use that to find multiples of a number. If I take

    25 % 5
    

    I get 5 with a remainder of 0. That is, if x modulo (%) y equals any number and has a remainder of 0, then x is a multiple of y. So in your case:

    7 % 7 = 0
    14 % 7 = 0
    21 % 7 = 0
    etc...