login
a(n) is the smallest integer k > 2 that satisfies k mod j <= 2 for all integers j in 1..n.
3

%I #25 Jun 02 2023 10:20:52

%S 3,3,3,4,5,6,30,42,56,72,792,792,1080,1080,1080,30240,246961,246961,

%T 636482,636482,1360801,2162162,2162162,2162162,39412802,39412802,

%U 107881202,107881202,3625549202,3625549202,3625549202,170918748001,170918748001,170918748001,170918748001,170918748001

%N a(n) is the smallest integer k > 2 that satisfies k mod j <= 2 for all integers j in 1..n.

%H Chai Wah Wu, <a href="/A361247/b361247.txt">Table of n, a(n) for n = 1..40</a>

%e a(7)=30 since 30 mod 7 = 2, 30 mod 6 = 0, 30 mod 5 = 0, 30 mod 4 = 2, 30 mod 3 = 0, 30 mod 2 = 0 and 30 is the smallest integer greater than 2 where all of these remainders are 2 or less.

%o (Python)

%o final=100

%o k=3

%o for n in range(1, final+1):

%o j = n+1

%o while (j > 2):

%o j -= 1

%o if k%j>2:

%o k += j-(k%j)

%o j = n+1

%o print(k)

%o (PARI) isok(k, n) = for (j=1, n, if ((k % j) > 2, return(0))); return(1);

%o a(n) = my(k=3); while(!isok(k, n), k++); k; \\ _Michel Marcus_, Mar 17 2023

%Y Cf. A003418 (all remainders 0).

%Y Cf. also A361246, A361248.

%Y Equals {A056697}+1. - _Hugo Pfoertner_, May 11 2023

%K nonn

%O 1,1

%A _Andrew Cogliano_, Mar 05 2023

%E a(32)-a(36) from _Chai Wah Wu_, Apr 24 2023