Unnamed
public text v1 · immutable#include <stdio.h>
#define MAX 200000
long int Tot[MAX]; // Calculated Euler totients
void initTot(int n)
{
for (int i=0; i<=n; i++)
Tot[i] = i;
}
void findTot (int n)
{
Tot[0] = Tot[1] = 0;
for (int i = 2; i<=n; i++){
if (Tot[i] != i)
continue;
for (int j = i; j <= n; j += i) {
Tot[j] = Tot[j]*(i-1)/i;
}
}
}
int main()
{
long int n;
initTot(MAX);
findTot(MAX);
return 0;
}