Primes with a Twist
Given an integer n(1<=n<=10^4), you need to count the numbers, x,< n, which are co-prime to 'n', i.e. gcd(x,n)=1.
Formally, given n, you need to find f(n)=[{x<n:gcd(x,n)=1}].
Return the count of the number of co-primes of 'n'.


Input Specification:

input1:the integer 'n'

output Specification :

Return the count of the number of co-prime of  'n' 

Example 1:

input1: 
Output2: 

Explanation:

Integers 1 and 3 are co-prime to 4, but 2 is not.

Example 2:

input1: 16
Output2: 8

 Explanation:

Integers 1,3,5,7,9,11,13 and 15are co-prime to 16.

Answer are :

 
x = int(input(""));
count1=int(1);
res =1;
count2=count1;
while count1!=x:
    res = count1 % 2;
    if res!=0:
        count2=count2+1;
    count1=count1+1
print(count2-1)

 



Share to whatsapp

More Questions from Entrance Exam Questions Module 1

Write a program that will take one string as input. The program will then remove vowels a, e, i, o, u from the string. If there are two or more than two vowels that occur together then the program shall ignore all of those vowels.
View
"Farway Home" is an online platform where users can buy property. This platform has a list of N plots numbered 0 to (N-1). The list consist of the specified area for each plot. The platform provides an application where a user can identify the plots with the Kth largest area from the list.
Write an algorithm to find the plot with the Kth largest area.
Input The first line of the input consists of an integer-size, representing the number of plats (N). The second line consists of N space separated integers-areas0, area1 ...... areaN-1, representing the areas of the plots.
The last line consists of an integer value, representing the value for which the user wishes to find the area (K).
View
Primes with a Twist
Given an integer n(1<=n<=10^4), you need to count the numbers, x,< n, which are co-prime to 'n', i.e. gcd(x,n)=1.
Formally, given n, you need to find f(n)=[{x<n:gcd(x,n)=1}].
Return the count of the number of co-primes of 'n'.
View