diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-12-06 14:55:30 +0000 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-12-06 14:55:30 +0000 |
| commit | cd04687f29d4ebea2fd5ec165585b21f2951f413 (patch) | |
| tree | 5c17b623d6b7a8cb803a4464f19d157152143e62 /challenge-141/mohammad-anwar/python/ch-1.py | |
| parent | fe57a0405720a40beaeb75100e069aaa13e4c49e (diff) | |
| parent | b9773f5c38387d865a093d2ecdfd1b01b4452c34 (diff) | |
| download | perlweeklychallenge-club-cd04687f29d4ebea2fd5ec165585b21f2951f413.tar.gz perlweeklychallenge-club-cd04687f29d4ebea2fd5ec165585b21f2951f413.tar.bz2 perlweeklychallenge-club-cd04687f29d4ebea2fd5ec165585b21f2951f413.zip | |
Merge branch 'master' into devel
Diffstat (limited to 'challenge-141/mohammad-anwar/python/ch-1.py')
| -rw-r--r-- | challenge-141/mohammad-anwar/python/ch-1.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/challenge-141/mohammad-anwar/python/ch-1.py b/challenge-141/mohammad-anwar/python/ch-1.py new file mode 100644 index 0000000000..b07284649b --- /dev/null +++ b/challenge-141/mohammad-anwar/python/ch-1.py @@ -0,0 +1,46 @@ +#!/usr/bin/python3 + +''' + +Week 141: + + https://theweeklychallenge.org/blog/perl-weekly-challenge-141 + +Task #1: Number Divisors + + Write a script to find lowest 10 positive integers having exactly 8 divisors. + +''' + +import unittest + +def number_divisors(count, number): + numbers = [] + i = 1 + + while len(numbers) < count: + divisors = [] + for j in range(1, i+1): + if i % j == 0: + divisors.append(j) + + if len(divisors) == number: + numbers.append(i) + + i += 1 + + return numbers + +# +# +# Unit test class + +class TestJortSort(unittest.TestCase): + + def test_example_1(self): + self.assertEqual( + number_divisors(10, 8), + [24, 30, 40, 42, 54, 56, 66, 70, 78, 88], + 'Example 1') + +unittest.main() |
