Answer to Question #324913 in Python for Vanitha

Question #324913

Indivisible Numbers(using nested for loops)



fin



number of positive integers K <= N such that K is not



for



4



5



You are given a positive integer N Your task is to find the divisible by any of the following numbers 2, 3, 4, 5, 6, 7, 8, 9, 10



6 prin



Custa



Input



The first line of input is an integer N



Output



The output should be an integer representing the number of positive integers satisfying the above condition.



Explanation



In the given sample input



N = 11



1 is not divisible by any of 2, 3, 4, 5, 6, 7, 8, 9, 10



2 is divisible by



2



3 is divisible by 3



11 is not divisible by any of 2, 3, 4, 5, 6, 7, 8, 9, 10



There are two numbers that are not divisible by 2, 3, 4, 5, 6, 7,



8, 9, 10



So the count is 2.



So, the output should be 2.


Sample Input 1



11



Sample Output 1



2



4



5



6 prin



Sample Input 2



12



Sample Output 2



2



Sample Input 3



268



Sample Output 3



47



1
Expert's answer
2022-04-06T13:54:28-0400
intp = int(input(">> "))
count = 0
for i in range(1, intp + 1):
    bad_number = False
    for j in range(2, 11):
        if i % j == 0:
            bad_number = True
            break
    if bad_number == False:
        count += 1
print(count)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS