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.
%I A327650 #24 May 14 2023 09:05:58 %S A327650 0,1,1,3,4,3,6,3,3,9,9,9,9,13,12,11,16,9,18,9,18,15,18,9,24,9,9,27,28, %T A327650 27,30,27,27,33,33,27,36,37,27,27,40,39,42,37,36,41,42,33,48,49,48,35, %U A327650 52,27,53,27,54,57,57,27,60,61,54,59,61,45,66,63,54,51 %N A327650 Maximum value of powers of 3 mod n. %H A327650 Rémy Sigrist, <a href="/A327650/b327650.txt">Table of n, a(n) for n = 1..6561</a> %H A327650 Rémy Sigrist, <a href="/A327650/a327650.png">Colored scatterplot of the ordinal transform of the first 3^10 terms</a> (colored pixels correspond to n's such that a(n) is a power of 3) %F A327650 a(3^k) = 3^(k-1) for any k > 0. %F A327650 a(3^k + 1) = 3^k for any k >= 0. %F A327650 a(3^k - 1) = 3^(k-1) for any k > 0. %e A327650 For n = 12: %e A327650 - the first powers of 3 mod 12 are: %e A327650 k 3^k mod 12 %e A327650 -- ---------- %e A327650 0 1 %e A327650 1 3 %e A327650 2 9 %e A327650 3 3 %e A327650 - those values are eventually periodic, the maximum being 9, %e A327650 - hence a(12) = 9. %t A327650 a[n_] := PowerMod[3, Range[0, n-1], n] // Max; %t A327650 Table[a[n], {n, 1, 1000}] (* _Jean-François Alcover_, May 14 2023 *) %o A327650 (PARI) a(n) = { my (p=1%n, mx=p); while (1, p=(3*p)%n; if (mx<p, mx=p, mx==p || p==0, return (mx))) } %Y A327650 Cf. A000244, A327649. %K A327650 nonn %O A327650 1,4 %A A327650 _Rémy Sigrist_, Sep 21 2019