public void MinnOverPhin() { var expected = 49; var actual = Totient.MinnOverPhin(100); Assert.Equal(expected, actual); }
public void TotientPerformance() { if (!bRunExpensive) { return; } Ticker tick = new Ticker(); Totient tot = new Totient(p, 9900000); tick.Tick("Generated first ~ten million"); int iMax; iMax = 0; while (!tick.SecondsElapsed(5) && iMax < 1000000) { iMax++; tot.Crappy(iMax); } tick.Tick("Crappy Max Value = " + iMax); iMax = 0; while (!tick.SecondsElapsed(5) && iMax < 1000000) { iMax++; tot.OK(iMax); } tick.Tick("OK Max Value = " + iMax); iMax = 0; while (!tick.SecondsElapsed(5) && iMax < 1000000) { iMax++; tot.Best(iMax); } tick.Tick("Best Max Value = " + iMax); }
public E070TotientPermutation(int size) { primeFactors = Primes.GetPrimeFactorsBelowNumber((long)size); primeDict = primeFactors.ToDictionary(e => e); vSize = size; totient = new Totient(size); }
public void Phi2() { var expected = 10083087720778; var actual = Totient.Phi2(10083087720779); Assert.Equal(expected, actual); }
public void ShowResult() { Totient totientManager = new Totient(); Permutation permutationManager = new Permutation(); double minimum = double.MaxValue; int minimumIndex = 2; for (int n = minimumIndex; n <= UPTO; n++) { var phi = totientManager.GetPhi(n); if (permutationManager.IsPermutation(n, phi)) { double totient = n / phi; if (totient < minimum) { minimum = totient; minimumIndex = n; } } } _output.WriteLine(minimumIndex.ToString()); const int expected = 8319823; int actual = minimumIndex; Assert.Equal(expected, actual); }
public void PhiPhi2() { var totient = new Totient(100); var expected = totient.Phi(20); var actual = Totient.Phi2(20); Assert.Equal(expected, actual); }
public void PhiOne() { var expected = 1; var totient = new Totient(1); var actual = totient.Phi(1); Assert.Equal(expected, actual); }
public void PhiMaxSet() { var expected = 3852; var totient = new Totient(4800); var actual = totient.Phi(4501); Assert.Equal(expected, actual); }
public void Test_Ytelse() { int antall = 10000; var sut = new Totient(antall); for (int i = 1; i < antall; i++) { sut.Calc(i); } }
public void OkTest() { Totient t = new Totient(p); for (int i = 1; i < iaTots.Length; i++) { Assert.AreEqual(iaTots[i], t.OK(i)); } Assert.AreEqual(3015360, t.OK(9799998)); Assert.AreEqual(2799792, t.OK(9799398)); Assert.AreEqual(3195896, t.OK(9796398)); Assert.AreEqual(400000, t.OK(1000000)); }
public void CrappyTest() { Totient t = new Totient(null); for (int i = 1; i < iaTots.Length; i++) { Assert.AreEqual(iaTots[i], t.Crappy(i)); } if (bRunExpensive) { //Assert.AreEqual(3015360, t.Crappy(9799998)); //Assert.AreEqual(2799792, t.Crappy(9799398)); //Assert.AreEqual(3195896, t.Crappy(9796398)); Assert.AreEqual(400000, t.Crappy(1000000)); } }
public void PrecalcTest() { Totient t = new Totient(p, iaTots.Length); for (int i = 1; i < iaTots.Length; i++) { Assert.AreEqual(iaTots[i], t.Best(i)); } if (bRunExpensive) { //t = new Totient(p, 9900000); Assert.AreEqual(3015360, t.Best(9799998)); Assert.AreEqual(2799792, t.Best(9799398)); Assert.AreEqual(3195896, t.Best(9796398)); Assert.AreEqual(400000, t.Best(1000000)); } }
public string Run() { var phi = Totient.UpTo(ONE_MILLION); double max = 0; int idx = 0; for (int i = 1; i <= ONE_MILLION; i++) { var ratio = (double)i / (double)phi[i]; if (ratio > max) { max = ratio; idx = i; } } return(idx.ToString()); }
public string Run() { var phis = Totient.UpTo(TEN_MILLION); double minRatio = double.MaxValue; long minN = 0; for (long i = 2; i <= TEN_MILLION; i++) { if (i.IsPermutationOf(phis[i])) { var ratio = (double)i / (double)phis[i]; if (ratio < minRatio) { minRatio = ratio; minN = i; } } } return(minN.ToString()); }
public E069TotientMaximum(int size) { vSize = size; totient = new Totient(1000000); }
public long GetNumberOfProperFractions(int dmax) { Totient totient = new Totient(dmax); return(Enumerable.Range(2, dmax - 1).Select(i => totient.Calc(i)).Sum()); }
public string Run() { var phi = Totient.UpTo(ONE_MILLION); return(phi.Skip(2).Sum().ToString()); }
public void Test_Totient(int n, int phi) { var sut = new Totient(1000000); Assert.Equal(phi, sut.Calc(n)); }
public void PhiGreaterThanN() { var totient = new Totient(10); Assert.Throws <ArgumentOutOfRangeException>(() => totient.Phi(20)); }