OFFSET
1,2
COMMENTS
For every positive integer n, there exists an integer k such that 2^k + k is divisible by n. The proof is given in the link, p. 63.
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
International Mathematical Olympiad, Problem N7, IMO-2006, p. 63.
EXAMPLE
a(7) = 6 because 2^6 + 6 = 70 is divisible by 7.
MAPLE
f:= proc(n) local k;
for k from 1 do
if 2^k + k mod n = 0 then return k fi
od
end proc:
seq(f(n), n=1..100); # Robert Israel, Dec 01 2014
MATHEMATICA
Table[s=0; k=0; While[k++; s=Mod[2^k+k, n]; s>0]; k, {n, 50}]
lk[n_]:=Module[{k=1}, While[Mod[2^k+k, n]!=0, k++]; k]; Array[lk, 120] (* Harvey P. Dale, Jun 18 2022 *)
PROG
(Python)
def A247248(n):
....if n == 1:
........return 1
....else:
........x, k, kr = 1, 0, 0
........while (x+kr) % n:
............x, kr = (2*x) % n, (kr+1) % n
............k += 1
........return k
# Chai Wah Wu, Dec 03 2014
(PARI) a(n) = for(m=1, oo, if(Mod(2, n)^m==-m, return(m))); \\ Jinyuan Wang, Mar 15 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Dec 01 2014
STATUS
approved