public void Test_Ytelse() { int antall = 10000; var sut = new Totient(antall); for (int i = 1; i < antall; i++) { sut.Calc(i); } }
public int GetNWithMaxTotient() { double maxNtoPhi = Double.MinValue; int maxN = -1; for (int n = 2; n < vSize; n++) { long phi = totient.Calc(n); // n / φ(n) double nToPhi = 1.0 * n / phi; if (nToPhi > maxNtoPhi) { maxNtoPhi = nToPhi; maxN = n; } } return(maxN); }
public int GetNWithMinTotient() { double minNtoPhi = Double.MaxValue; int minN = -1; for (int n = 2; n < vSize; n++) { long phi = totient.Calc(n); if (Permutation.IsPermuted(phi, n)) { // n / φ(n) double nToPhi = 1.0 * n / phi; if (nToPhi < minNtoPhi) { minNtoPhi = nToPhi; minN = n; } } } return(minN); }
public long GetNumberOfProperFractions(int dmax) { Totient totient = new Totient(dmax); return(Enumerable.Range(2, dmax - 1).Select(i => totient.Calc(i)).Sum()); }
public void Test_Totient(int n, int phi) { var sut = new Totient(1000000); Assert.Equal(phi, sut.Calc(n)); }