-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprimeNumber.py
More file actions
23 lines (17 loc) · 807 Bytes
/
primeNumber.py
File metadata and controls
23 lines (17 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import math
# Welcome message and program description
print("Welcome! This program finds all numbers that are coprime with a given integer and calculates its Euler's totient function.\n")
# Get user input for an integer greater than 1
number = int(input("Enter an integer greater than 1: "))
coprime_numbers = []
if number <= 1:
print("Invalid number")
else:
# Check all numbers from 1 to (number - 1)
for i in range(1, number):
# If gcd is 1, numbers are coprime
if math.gcd(i, number) == 1:
coprime_numbers.append(i)
# Print the list of coprime numbers and Euler's totient function value
print(f"Numbers that are coprime with {number}: {coprime_numbers}")
print(f"Euler's totient function value for {number} is {len(coprime_numbers)}")