public void PrimesTest() { var n = Sequences.Primes().Skip(99999).First(); Assert.AreEqual(1299709L, n); //var n = Sequences.Primes().Skip(999999).First(); //Assert.AreEqual(15485863L, n); }
public void RulerSkipTest() { var r1 = Sequences.Ruler().Skip(1000000).Take(100).ToList(); var r2 = Sequences.Ruler(1000000).Take(100).ToList(); for (int i = 0; i < 100; i++) { Assert.AreEqual(r1[i], r2[i]); } }
public void RulerTest() { var n = Sequences.Ruler().Take(20).ToArray(); var expected = new[] { 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, }; for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], n[i] + 1, "Position " + i); } }
public void FactorialsBigTest() { var g = Sequences.OverFactorials().ToList(); var f = Sequences.FactorialsB().Take(g.Count).ToList(); for (var i = 0; i < g.Count; i++) { var x = (double)f[i] * g[i]; Assert.IsTrue(Math.Abs(x - 1) < 1e-15); } }
public void OverFactorialsTest() { var f = Sequences.OverFactorials().ToList(); for (int i = 2; i < f.Count; i++) { Assert.IsTrue(f[i] < f[i - 1]); } Show(f, _ => $"{_:r}, "); }
public void FactorialsDoubleTest() { var f = Sequences.FactorialsD().ToList(); for (int i = 2; i < f.Count; i++) { Assert.IsTrue(f[i] > f[i - 1]); } Show(f, _ => $"{_:r}, "); }
public void RulerPartialSumTest() { var n = Sequences.Ruler().Take(100000).Sum(); Assert.AreEqual(99994, n); }