Raj Kumar
Computer Science And Engineering

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'.

Entrance Exam Questions

Explanation

1259    0

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:   
   Raj Kumar
Computer Science And Engineering

More Questions from Entrance Exam Questions Module 1