13238273
13631489
16121857
16384001
18841601
19824641
20054017
21626881
22806529
23789569
24576001
27688961
28311553
29884417
35200001
35389441
35684353
38535169
sum of them are 441588754. But it seems incorrect. here is my Eulerfi function. where is my mistake?
Code: Select all
public static int Eulerfi(int n)
{
if(isprime(n))
return n-1;
Set set = new HashSet();
int hasil = 1;
int cem = 1;
int a = n;
for(int i=2; i<=n; i++)
{
if(n%i==0 && isprime(i))
{
n /= i;
set.add(i);
hasil *= (i - 1);
cem *= i;
}
}
return a*hasil/cem;
}
