\\ A401136 -- self-contained check program, PARI/GP. \\ \\ Square array read by antidiagonals downwards: \\ Y(n,k) = (product of the first n-1 primes)*prime(n)^k - 1 for n, k >= 1. \\ \\ Run: gp -q A401136.gp \\ \\ The program computes the first 140 antidiagonals, 9870 terms, from the \\ definition and checks them: \\ \\ * the 36 terms of the entry's DATA field; \\ * row 1 against 2^k - 1, and column 1 against the product of the first n \\ primes minus 1; \\ * the row recurrence Y(n,k) = prime(n)*Y(n,k-1) + prime(n) - 1 at every cell \\ with k >= 2; \\ * if the b-file b401136.txt (or b401136_1.txt) is in the current directory, \\ every term against it, line by line. \\ \\ Reading order: antidiagonal d holds Y(1,d), Y(2,d-1), ..., Y(d,1), so the row \\ index n increases along it ("downwards"), and Y(n,k) is term number \\ a((n+k-1)*(n+k-2)/2 + n). \\ \\ The Python program A401136.py makes the same checks and, in addition, \\ compares a SHA-256 fingerprint of the terms with the b-file uploaded to the \\ OEIS, so it needs no download. D = 140; DATA = [1, 3, 5, 7, 17, 29, 15, 53, 149, 209, 31, 161, 749, 1469, 2309, 63, 485, 3749, 10289, 25409, 30029, 127, 1457, 18749, 72029, 279509, 390389, 510509, 255, 4373, 93749, 504209, 3074609, 5075069, 8678669, 9699689]; BFILES = ["b401136.txt", "b401136_1.txt"]; \\ The index m with a(m) = Y(n,k). position(n, k) = (n + k - 1) * (n + k - 2) / 2 + n; \\ a(1), ..., a(D*(D+1)/2): Y(n,k) for n + k <= D + 1, by antidiagonals. compute() = { my(P = primes(D), h = vector(D), v = vector(D * (D + 1) / 2), m = 0); h[1] = 1; for(n = 2, D, h[n] = h[n - 1] * P[n - 1]); \\ h[n] = product of the first n-1 primes for(d = 1, D, for(n = 1, d, v[m++] = h[n] * P[n]^(d + 1 - n) - 1)); v; } \\ The lines of a b-file as [m, a(m)], skipping comment and blank lines; \\ 0 if the file cannot be read. readBfile(name) = { my(L = iferr(readstr(name), E, 0), out = List(), w); if(type(L) != "t_VEC", return(0)); for(i = 1, #L, if(#L[i] && Vecsmall(L[i])[1] != 35, \\ 35 = "#" w = strsplit(L[i], " "); listput(out, [eval(w[1]), eval(w[2])]))); Vec(out); } \\ Print one check's result; return 1 if it failed. check(label, good) = printf("%s: %s\n", label, if(good, "ok", "FAILED")); !good; verify() = { my(t0 = getabstime(), T = compute(), P = primes(D), Yv, bad = 0, ok, pr, cells, B, name, wrong); Yv = ((n, k) -> T[position(n, k)]); \\ parenthesised: a bare -> would take in the rest of the body printf("A401136: %d terms = antidiagonals 1..%d, largest %d digits\n", #T, D, vecmax(apply(x -> #Str(x), T))); bad += check(Str("DATA (", #DATA, " terms)"), T[1..#DATA] == DATA); ok = 1; for(k = 1, D, if(Yv(1, k) != 2^k - 1, ok = 0)); bad += check(Str("row 1 = 2^k - 1 for k = 1..", D), ok); ok = 1; pr = 1; for(n = 1, D, pr *= P[n]; if(Yv(n, 1) != pr - 1, ok = 0)); bad += check(Str("column 1 = A002110(n) - 1 for n = 1..", D), ok); ok = 1; cells = 0; for(n = 1, D, for(k = 2, D + 1 - n, cells++; if(Yv(n, k) != P[n] * Yv(n, k - 1) + P[n] - 1, ok = 0))); bad += check(Str("Y(n,k) = prime(n)*Y(n,k-1) + prime(n) - 1 at all ", cells, " cells with k >= 2"), ok); B = 0; for(i = 1, #BFILES, B = readBfile(BFILES[i]); if(type(B) == "t_VEC", name = BFILES[i]; break)); if(type(B) != "t_VEC", print("b-file: none in this directory (optional; download b401136.txt from the OEIS to compare)"), wrong = 0; for(i = 1, #B, if(B[i][1] < 1 || B[i][1] > #T || T[B[i][1]] != B[i][2], wrong++; if(wrong <= 5, printf("MISMATCH at a(%d): computed %s, b-file has %d\n", B[i][1], if(B[i][1] >= 1 && B[i][1] <= #T, Str(T[B[i][1]]), "nothing"), B[i][2])))); bad += check(Str("b-file ", name, ": ", #B, " terms, all equal"), !wrong && vector(#B, i, B[i][1]) == vector(#T, i, i))); if(bad, printf("FAILED: %d check(s) did not pass.\n", bad), printf("OK: all checks passed. Total %d s.\n", (getabstime() - t0) \ 1000)); !bad; } \\ When the file is run directly (gp -q A401136.gp), check and quit. \\ To load the functions without running, comment out the next two lines. verify(); quit;