Hello, I am learning programming and just discovered this website. But I am curious, how does it protect its users from spammers (people who post illegal or annoying things) without a reCaptcha? I thought clicking this blue box is required to prove that you are not a robot, can you please share any javascript that you use for this purpose? Thank you and have a nice day, Brian
Name:
Anonymous2021-06-06 2:53
Unaccelerated π stream from https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5.3 "Exploiting the Stream Paradigm". It converges rather slowly. The gcd is borrowed from the gcdlcm >>108,123,124 decorator and the fraction display from the broccoli >>115 decorator. (n => { const step = state => { const [a, b, fa, fb, ga, gb] = state; const m = a % b, d = (a - m) / b; state[0] = b; state[1] = m; state[2] = ga; state[3] = gb; state[4] = fa - d * ga; state[5] = fb - d * gb; } const gcdn = (a, b) => { const state = [a, b, 1n, 0n, 0n, 1n]; while (state[1] != 0n) { step (state); } return [state[0], state[2], state[3]]; } const reduce = f => { const [g, fa, fb] = gcdn (f [0], f [1]); if (g > 1) { f [0] /= g; f [1] /= g; } return f; } const add = (f1, f2) => [f1 [0] * f2 [1] + f1 [1] * f2 [0], f1 [1] * f2 [1]] const parts = function* () { let a = 4n, b = 1n; for (;;) { yield [a, b]; [a, b] = [-a, b + 2n]; } } const accum = function* (parts, init, step, emit) { let acc = init, x; for (;;) { x = parts.next ().value; acc = step (acc, x); yield emit (acc); } } const pi = accum (parts (), [0n, 1n], (f, x) => reduce (add (f, x)), f => f) const show1 = ([a, b]) => a.toString () + ' / ' + b.toString () + ' = ' const show2 = (digits => (power => ([a, b]) => (a / b).toString () + '.' + (a % b * power / b).toString ().padStart (digits, '0')) (BigInt (10) ** BigInt (digits))) (60) const diff = (s1, s2) => { let n = Math.min (s1.length, s2.length); for (let k = 0; k < n; k++) { if (s1 [k] !== s2 [k]) { return k; } } return n < s2.length ? n : -1; } const marker = (s, pos) => pos < 0 ? s : (s.substring (0, pos) + '_' + s.substring (pos)) for (let k = 0, p = pi, x = p.next ().value, prev = ''; k < n; k++, x = p.next ().value) { let now = show2 (x); console.log (show1 (x) + (prev === '' ? now : marker (now, diff (prev, now)))); prev = now; } })(20)