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 A003571 #19 Oct 22 2023 16:19:28 %S A003571 1,2,6,4,3,4,18,5,20,6,30,16,18,4,42,11,42,6,20,28,10,16,22,12,12,18, %T A003571 78,8,16,10,6,23,48,20,34,52,27,12,44,29,5,30,126,12,18,16,138,35,28, %U A003571 18,50,30,78,8,162,41,39,42,60,88,45,22,80,36,16,42,198,100,8 %N A003571 Order of 3 mod 3n+1. %H A003571 Muniru A Asiru, <a href="/A003571/b003571.txt">Table of n, a(n) for n = 0..5000</a> %p A003571 a := n -> `if`(n=0, 1, numtheory:-order(3, 3*n+1)): %p A003571 seq(a(n), n = 0..68); %t A003571 Table[MultiplicativeOrder[3, 3*n + 1], {n, 0, 68}] (* _Arkadiusz Wesolowski_, Nov 27 2012 *) %o A003571 (Sage) %o A003571 def A003571(n): %o A003571 s, m, N = 0, 1, 3*n + 1 %o A003571 while True: %o A003571 k = N + m %o A003571 v = valuation(k, 3) %o A003571 s += v %o A003571 m = k // 3^v %o A003571 if m == 1: break %o A003571 return s %o A003571 print([A003571(n) for n in (0..68)]) # _Peter Luschny_, Oct 07 2017 %o A003571 (GAP) List([0..70],n->OrderMod(3,3*n+1)); # _Muniru A Asiru_, Feb 16 2019 %o A003571 (PARI) a(n) = znorder(Mod(3, 3*n+1)); \\ _Michel Marcus_, Feb 16 2019 %Y A003571 Cf. A002326, A003573, A217469. %K A003571 nonn %O A003571 0,2 %A A003571 _N. J. A. Sloane_ %E A003571 a(0) = 1 added by _Peter Luschny_, Oct 07 2017