Returns the count of the numbers from 1 to N, inclusive, that are divisible by argument a or argument b, but not both

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.4: Program Input Using Cin
Problem 9E
icon
Related questions
Question

import unittest
# ------------------------------------------------------------
def enumerate6(N, a, b) :
'''
Assumes that N, a, b are positive integers.
Returns the count of the numbers from 1 to N, inclusive,
that are divisible by argument a or argument b, but not both

For example, enumerate6(10, 2, 5) returns 5,
since 2, 4, 5, 6, 8 are the numbers from 1 to 10 that
are divisible by 2 or 5 but not both
'''
pass
# --------------------------------------------------------------
# The Testing
# --------------------------------------------------------------
class myTests(unittest.TestCase):
def test1(self):
ans = enumerate6(10, 2, 5)
self.assertEqual(ans, 5)
def test2(self):
ans = enumerate6(12, 2, 5)
self.assertEqual(ans, 6)
def test3(self):
ans = enumerate6(5000, 4, 2)
self.assertEqual(ans, 1875)
def test4(self):
ans = enumerate6(50000, 3, 8)
self.assertEqual(ans, 18750)
def test5(self):
ans = enumerate6(12131, 7, 2)
self.assertEqual(ans, 6066)


if __name__ == '__main__':
unittest.main(exit=True)

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Counting Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr