function coef(n) { for (var c=[1], i=0; i0 ? ' +' : ' ') + cs[n] + (n==0 ? '' : n==1 ? 'x' :'x'+n+''); while (n--) return s } function isPrime(n) { var cs=coef(n), i=n-1; while (i-- && cs[i]%n == 0); return i < 1 } for (var n=0; n<=7; n++) document.write('(x-1)',n,' = ', show(coef(n)), '
') document.write('
Primes: '); for (var n=2; n<=50; n++) if (isPrime(n)) document.write(' ', n)