private static IEnumerable <int> GenDigits() { var k = 1; var n1 = new GmpInteger(4); var n2 = new GmpInteger(3); var d = new GmpInteger(1); var u = new GmpInteger(); var v = new GmpInteger(); var w = new GmpInteger(0); while (true) { // digit u.Div(n1, d); v.Div(n2, d); if (u.Cmp(v) == 0) { yield return(u.IntValue()); // extract u.Mul(u, -10); u.Mul(u, d); n1.Mul(n1, 10); n1.Add(n1, u); n2.Mul(n2, 10); n2.Add(n2, u); } else { // produce var k2 = k * 2; u.Mul(n1, k2 - 1); v.Add(n2, n2); w.Mul(n1, k - 1); n1.Add(u, v); u.Mul(n2, k + 2); n2.Add(w, u); d.Mul(d, k2 + 1); k++; } } }
public int Cmp(GmpInteger op1) => mpz_cmp(ref pointer, ref op1.pointer);
public void Div(GmpInteger op1, GmpInteger op2) => mpz_tdiv_q(ref pointer, ref op1.pointer, ref op2.pointer);
public void Sub(GmpInteger op1, GmpInteger op2) => mpz_sub(ref pointer, ref op1.pointer, ref op2.pointer);
public void Add(GmpInteger op1, GmpInteger op2) => mpz_add(ref pointer, ref op1.pointer, ref op2.pointer);
public void Mul(GmpInteger src, int val) => mpz_mul_si(ref pointer, ref src.pointer, val);
public void Mul(GmpInteger op1, GmpInteger op2) => mpz_mul(ref pointer, ref op1.pointer, ref op2.pointer);