Answer to Question #292914 in Python for gayathri

Question #292914

you are given a positive integer n. your task is to find the number of positive integers k<=n such that k is not divisible by any of the following numbers 2,3,4,5,6,7,8,9,10.


1
Expert's answer
2022-02-04T01:44:43-0500
# enter the number
n = int(input("Enter the number: "))
number = 0
for i in range(1,n+1):
    if i % 2 != 0 and i % 3 != 0 and i % 4 != 0 and i % 5 != 0 and i % 6 != 0 and i % 7 != 0 and i % 8 != 0 and i % 9 != 0 and i % 10 != 0:
        number += 1
print(number)

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