%I #13 Feb 02 2022 23:40:27
%S 21,1,1,41,145,9,13,441,409,541,19,29,715,33,625,37,4321,25,51,44,57,
%T 49,63,17,69,6937,8009,3349,49,33,12161,21385,109,8961,61,10945,113,
%U 123,21001,137,39961,22205,119,149,149,6001,12297,37409,171,36341,21,149
%N Numerator of the limiting density of residues attained by the Fibonacci sequence modulo powers of the n-th prime.
%C For a prime p, the limiting density of residues attained by the Fibonacci sequence modulo powers of p is the limit as m -> infinity of |{F(n) mod p^m : n >= 0}|/p^m.
%H Nicholas Bragman and Eric Rowland, <a href="https://arxiv.org/abs/2202.00704">Limiting density of the Fibonacci sequence modulo powers of p</a>, arXiv:2202.00704 [math.NT], 2022.
%H Eric Rowland and Reem Yassawi, <a href="http://dx.doi.org/10.1016/j.indag.2016.11.019">p-adic asymptotic properties of constant-recursive sequences</a>, Indagationes Mathematicae 28 (2017) 205-220.
%e Let p = 2. For all m >= 5, the residues attained modulo 2^m by the Fibonacci sequence have density 21/32.
%e Let p = 3. For all m >= 1, every residue modulo 3^m is attained by the Fibonacci sequence, so the density is 1.
%e Let p = 11. Rowland and Yassawi showed that the residues attained modulo 11^m by the Fibonacci sequence have approach density 145/264 as m -> infinity.
%t density[2] := 21/32
%t density[p_?PrimeQ /; p >= 3] := Module[{restrictedperiodlength = 1, periodlength, wallexponent, lucaszeros, fullresidues, partialresidues},
%t NestWhile[
%t Function[values,
%t restrictedperiodlength++;
%t Mod[{{0, 1}, {1, 1}}.values, p]
%t ],
%t {0, 1},
%t Function[values, Last[values] != 0]
%t ];
%t periodlength = SelectFirst[
%t {1, 2, 4} restrictedperiodlength,
%t Function[n, Mod[Fibonacci[n + 1], p] == 1]
%t ];
%t wallexponent = IntegerExponent[Fibonacci[restrictedperiodlength], p];
%t lucaszeros = Which[
%t OddQ[restrictedperiodlength], {},
%t !Divisible[restrictedperiodlength, 4], {restrictedperiodlength/2},
%t True, {restrictedperiodlength/2, (3 restrictedperiodlength)/2}
%t ];
%t fullresidues = DeleteDuplicates[Mod[Fibonacci[Complement[Range[0, periodlength - 1], lucaszeros]], p^wallexponent]];
%t partialresidues = DeleteDuplicates[Mod[Fibonacci[lucaszeros], p^wallexponent]];
%t Length[fullresidues]/p^wallexponent + Length[Complement[partialresidues, fullresidues]]/(2 p^(2 wallexponent - 1) (p + 1))
%t ]
%t Table[Numerator[density[p]], {p, Prime[Range[20]]}]
%Y The denominators are A351000.
%K nonn,frac
%O 1,1
%A _Eric Rowland_, Feb 02 2022