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 A349544 #25 Nov 27 2021 05:08:00 %S A349544 1,1,1,5,1,19,7,5,65,61,73,227,257,5,439,1253,2425,2035,833,2677, %T A349544 10591,6509,32071,41173,77263,114323,18145,129685,321151,15757,645449, %U A349544 113957,50735,477653,24295,5089013,3743881,4809115,12209455,8216179,32894927,80299843,45673913 %N A349544 Smallest possible value of |Sum_{k=0..n} (+-) 2^k * 3^(n-k)|, where each (+-) can be either plus or minus sign, independently for each term in the sum. %C A349544 All terms are positive odd integers. %H A349544 Math StackExchange, <a href="https://math.stackexchange.com/questions/4311886/minimizing-a-generalized-partial-sum-of-a-geometric-progression">Minimizing a generalized partial sum of a geometric progression</a> %e A349544 For n = 3, there are 2^3 = 8 possible choices of signs: 3^3 + 2*3^2 + 2^2*3 + 2^3 = 65, 3^3 + 2*3^2 + 2^2*3 - 2^3 = 49, 3^3 + 2*3^2 - 2^2*3 + 2^3 = 41, 3^3 + 2*3^2 - 2^2*3 - 2^3 = 25, 3^3 - 2*3^2 + 2^2*3 + 2^3 = 29, 3^3 - 2*3^2 + 2^2*3 - 2^3 = 13, 3^3 - 2*3^2 - 2^2*3 + 2^3 = 5, and 3^3 - 2*3^2 - 2^2*3 - 2^3 = -11. The smallest absolute value is 5, so a(3) = 5. %p A349544 b:= proc(k, n) option remember; `if`(k<0, {0}, map(x-> %p A349544 (t-> [x+t, abs(x-t)][])(2^(n-k)*3^k), b(k-1, n))) %p A349544 end: %p A349544 a:= n-> min(b(n$2)): %p A349544 seq(a(n), n=0..18); # _Alois P. Heinz_, Nov 21 2021 %t A349544 Min@*Abs/@FoldList[Join[3 #1 + 2^#2, 3 #1 - 2^#2] &, {1}, Range[25]] %o A349544 (Python) %o A349544 def f(k,n): %o A349544 if k == 0 and n == 0: return (x for x in (1,)) %o A349544 if k < n: return (y*3 for y in f(k,n-1)) %o A349544 return (abs(x+y) for x in f(k-1,n) for y in (2**n,-2**n)) %o A349544 def A349544(n): return min(f(n,n)) # _Chai Wah Wu_, Nov 24 2021 %Y A349544 Cf. A001047, A036561, A232111, A232112. %K A349544 nonn,hard %O A349544 0,4 %A A349544 _Vladimir Reshetnikov_, Nov 21 2021 %E A349544 a(33)-a(35) from _Chai Wah Wu_, Nov 24 2021 %E A349544 a(36)-a(42) from _Martin Ehrenstein_, Nov 26 2021