-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork.py
More file actions
33 lines (27 loc) · 885 Bytes
/
work.py
File metadata and controls
33 lines (27 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import math
def is_prime(n):
if n < 2:
return False
for i in range(2, int(math.isqrt(n)) + 1):
if n % i == 0:
return False
return True
def is_composite(n):
return n > 1 and not is_prime(n)
def count_divisors(n):
count = 0
for i in range(1, int(math.isqrt(n)) + 1):
if n % i == 0:
count += 1
if i != n // i:
count += 1
return count
def is_funny(n):
return is_composite(n) and is_prime(count_divisors(n))
def main():
l = int(input("Введіть початок проміжку l: "))
m = int(input("Введіть кінець проміжку m: "))
funny_count = sum(1 for x in range(l, m + 1) if is_funny(x))
print(f"Кількість кумедних чисел на проміжку [{l}; {m}]: {funny_count}")
if __name__ == "__main__":
main()