Question: Write a python function that takes a positive integer n as an argument. This function will return the number of positive integers less than n

Write a python function that takes a positive integer n as an argument.

This function will return the number of positive integers less than n that are co-prime to n.

Co-prime Numbers: Two numbers are coprime to each other if they dont have any common divisor except 1.

-----------------------------------------------------------------------------------------------------

Sample Input 1:

1 Sample Output 1:

0 Reason: Since 1 is the smallest positive integer , there exists no positive integer that is less than and coprime to 1.

-----------------------------------------------------------------------------------------------------

Sample Input 2:

2 Sample Output 2:

1

Reason: Only 1 doesnt share any common divisor (except 1 itself) with 2. Also, 1 < 2.

-----------------------------------------------------------------------------------------------------

Sample Input 3:

6 Sample Output 3:

2

Reason: Namely, the two coprime numbers to 6 are 1 and 5.

-----------------------------------------------------------------------------------------------------

Sample Input 4:

36

Sample Output 4:

12

Reason: The numbers coprime to 36 are 1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31 and 35

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!