Examveda

What will be the output of the following code in C++?
#include <stdio.h> 
int ETF(int n) 
{ 
    int a, result = n; 
    for (a = 2; a * a <= n; ++a)
    { 
        if (n % a == 0)
	{ 
	    while (n % a == 0) 
                n = n / a; 
	    result = result - result / a; 
	} 
    } 
    if (n > 1) 
        result = result - result / n; 
    return result; 
} 
int main() 
{ 
    int n; 
    for (n = 1; n <= 4; n++) 
        printf("%d\n", ETF(n)); 
    return 0; 
}

A. 0 1 2 3

B. 0 1 2 4

C. 1 1 2 2

D. 1 2 3 4

Answer: Option C


This Question Belongs to Data Structure >> Miscellaneous On Data Structures

Join The Discussion

Related Questions on Miscellaneous on Data Structures