Numbers without remainder python
Question: I need to print out numbers between 1 and n(n is entered with keyboard) that
do not divide by 2, 3 and 5. I need to use while or for loops and the
remainder is gotten with %. I'm new here and I just don't understand the usage
of %? I tried something like this:

    
    
    import math
    
    print("Hey. Enter a number.")
    
    entered_number = int(input())
    
    for i in range(1, entered_number):
    
        if i%2 != 0:
            print("The number", i, "is ok.")
        else:
            pass
        if i%3 != 0:
            print("The number", i, "is ok.")
        else:
            pass
        if i%5 != 0:
            print("The number", i, "is ok.")
    

help?


Answer: You need to test for all 3 conditions in **one** statement, not in 3:

    
    
    for i in range(1, entered_number):    
        if i % 2 != 0 and i % 3 != 0 and i % 5 != 0:
            print("The number", i, "is ok.")
    

The `and` operators here make sure that _all three_ conditions are met before
printing.

You are testing each condition in isolation, which means that if the number
is, say, 10, you are still printing `The number 10 is ok.` because it is not
divisible by 3. For numbers that _are_ okay, you were printing `The number ...
is ok.` 3 times, as your code tests that it is not divisible by 3 different
numbers separately, printing each time.

