cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A317650 The n-th term is the smallest integer > 1 that is congruent to +1 or -1 modulo k for all 2 <= k <= n.

This page as a plain text file.
%I A317650 #11 Aug 04 2018 06:31:59
%S A317650 3,5,5,11,11,29,41,71,71,881,1079,10009,10009,32759,82081,636481,
%T A317650 636481,2162161,2162161,2162161,2162161,39412801,39412801,39412801,
%U A317650 39412801,1074427199,1074427199,15362146799,15362146799,109271408401,482955026399,482955026399
%N A317650 The n-th term is the smallest integer > 1 that is congruent to +1 or -1 modulo k for all 2 <= k <= n.
%t A317650 Rest@ Nest[Function[a, Append[a, Block[{k = a[[-1]]}, While[! AllTrue[Table[Or[# == 1, # == m - 1] &@ Mod[k, m], {m, Length@ a + 1}], # &], k++]; k]]], {2}, 16] (* _Michael De Vlieger_, Aug 02 2018 *)
%o A317650 (PARI)
%o A317650 ok(n,m)={for(i=2, n, my(r=m%i); if(r<>1&&r<>i-1, return(0))); 1}
%o A317650 a(n)={my(m=oo, p=primes(primepi(n))); p=vector(#p, i, p[i]^logint(n, p[i]));
%o A317650 for(k=0, 2^#p-1, my(t=2+lift(-2+chinese(vector(#p, i, Mod(if(bittest(k, i-1), -1, 1), p[i]))))); if(t<m && ok(n,t), m=t)); m} \\ _Andrew Howroyd_, Aug 02 2018
%K A317650 nonn
%O A317650 2,1
%A A317650 _Kevin D. Woerner_, Aug 02 2018
%E A317650 a(21)-a(32) from _Andrew Howroyd_, Aug 02 2018