// Independent check: exact integrality of A276175 terms and the claimed 2-adic word w. const N = +process.argv[2] || 24; const w = [0,0,0,0,3,2,1,0,2,3,4, 0,0,0,0,3,2,1,0,2,3,4, 0,0,0,0,4,3,2,0,1,2,3, 0,0,0,0,4,3,2,0,1,2,3]; const t = [1,1,1,1,0,0,0,5,0,0,0, 2,1,1,1,0,0,0,5,0,0,0, 2,1,1,2,0,0,0,5,0,0,0, 1,1,1,2,0,0,0,5,0,0,0]; // balance law w_{n+4}+w_n = t_{n+1}+t_{n+2}+t_{n+3} (indices mod 44) for (let n = 0; n < 44; n++) { const L = w[(n+4)%44] + w[n], R = t[(n+1)%44] + t[(n+2)%44] + t[(n+3)%44]; if (L !== R) { console.log("balance law FAILS at n=" + n, L, R); process.exit(1); } } console.log("balance law holds for all 44 residues"); const v2 = x => { let k = 0; while ((x & 1n) === 0n) { x >>= 1n; k++; } return k; }; const a = [1n,1n,1n,1n]; for (let n = 4; n <= N; n++) { const num = (a[n-1]+1n)*(a[n-2]+1n)*(a[n-3]+1n); if (num % a[n-4] !== 0n) { console.log("NOT INTEGER at n=" + n); process.exit(1); } a.push(num / a[n-4]); } let ok = true; for (let n = 0; n <= N; n++) { const vw = v2(a[n]), vt = v2(a[n]+1n); if (vw !== w[n%44] || vt !== t[n%44]) { ok = false; console.log("mismatch n="+n, vw, w[n%44], vt, t[n%44]); } } const digits = a[N].toString().length; console.log(`a(0..${N}) all integers; v2(a_n)=w_n and v2(a_n+1)=t_n for all n<=${N}: ${ok}; a(${N}) has ${digits} digits`); const known = "1,1,1,1,8,36,666,222111,685187756,2819713283228248".split(","); console.log("first 10 match OEIS:", known.every((s,i)=>a[i].toString()===s));