Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-Question 2 (Homework) How many integers 0 105,00,000 are divisble ty at least o

ID: 3742638 • Letter: #

Question

-Question 2 (Homework) How many integers 0 105,00,000 are divisble ty at least one of . I suggest using 1050 when writing and testing code. Set N-105000000 ance you are confident your code works Everyone who turns in working code showing the correct answer will get full ctreda Extra credit for the fastest code Rules Only core python, no import statenents. There are many modiules (numpy,oytion.nutmibe eta) that speed python up a lot But, for faimess, this competition u limited to core python Timing based on Google Colab runtime Use the stimeit rbagl function as demanistrated above Instructions Create new colab notebook Create one text cell on top with your header (name, date, etc) .Create one or more code cells Run the code and print the answer. Including timing if you wish to compete for extra credit FilePrint. Hide any table of contents. Yes, I know it is weird to print this out rather thign subimit electronically But it is easiest for grading purposes this way If a/b is an integer, we say a is divisible by b b divides a in Python, a % b returns the remainder of a/b So, a is divisible by biffa%b"0. I I def divides(o, b)s remainder . % b does it divide (remainder e print(is (a) aivisible by (b)? (does It divide): (a) /(b) has rena inder renainder) divides(7.) divides (1e5, 3) Is 7 divisible by 3? False: 7/3 has renainder 1. sible by 3? True: 1850/3 has renainder

Explanation / Answer

n = 105000000 count = 0 for i in range(n+1): if i % 3 == 0 or i % 5 == 0 or i % 7 == 0: count += 1 print(count, 'numbers are divisible by atleast 3, 5 or 7')