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 A322108 #23 Apr 09 2019 05:10:28 %S A322108 1,3,7,15,29,50,79,118,169,233,311,405,517,648,799,972,1169,1391,1639, %T A322108 1915,2221,2558,2927,3330,3769,4245,4759,5313,5909,6548,7231,7960, %U A322108 8737,9563,10439,11367,12349,13386,14479 %N A322108 Distance of n-th iteration in an alternating rectangular spiral. %C A322108 This sequence is generated by taking the sum of each iteration in an alternating rectangular spiral. The rules for generating this spiral are as follows: %C A322108 1. The first iteration starts with one unit length. %C A322108 2. Each iteration must alternate the direction the spiral is going (if iteration 1 is counterclockwise, iteration 2 must be clockwise and vice versa). Every time the direction is changed, the next line will be 90 degrees in that direction from the ending of the spiral in that iteration. %C A322108 3. Each iteration must add one more line that has to be drawn before the iteration is over: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, etc. %C A322108 If we add the alternation to it and start by moving right and counterclockwise, we get something like: right, down, left, down, right, up, right, down, left, up. %C A322108 4. Every line drawn must go at least one unit length farther than the current outer bounds of the spiral. %C A322108 The sequence comes from the sums of these iterations. The first iteration is only one unit length, so the first term is 1. If the first iteration was counterclockwise and went one unit to the right, the second iteration will be clockwise and start by going one unit down. Because two lines must be drawn for the second iteration, we now have to go left 2 units in order to pass the leftward bound that the starting line created. This gives us a value of 3 for the second iteration because we traveled one unit down and two to the left. We can repeat this process for the third iteration. Now we return to moving counterclockwise and move one unit down. We must move three units to the left in order to pass the rightward bound created by the first iteration. Now we must move three units up in order to pass the upper bound created by the first iteration. When we add 1 + 3 + 3 we get 7 which is the next term in the sequence. %H A322108 Drew Edgette, <a href="/A322108/a322108.png">Picture of Alternating Rectangular Spiral</a> %F A322108 Conjectures from _Colin Barker_, Feb 13 2019: (Start) %F A322108 G.f.: x*(1 - x + 2*x^2 + x^4) / ((1 - x)^4*(1 + x^2)). %F A322108 a(n) = (2 - (-i)^n - i^n + 6*n - 2*n^2 + 2*n^3) / 8 where i=sqrt(-1). %F A322108 (End) %o A322108 (Python with Turtle) %o A322108 import turtle %o A322108 t = turtle.Turtle()t.hideturtle()t.pensize(1)t.right(90)t.speed(8)t.pendown()j = 1 %o A322108 xMin = 0xMax = 0 %o A322108 yMin = 0yMax = 0 %o A322108 sz = 10 %o A322108 alist = []blist = [] %o A322108 for i in range(15): %o A322108 while j <= i: %o A322108 t.color("red") %o A322108 if i % 2 == 0: t.right(90) else: t.left(90) %o A322108 if j == 1: if t.heading() == 0: t.forward(sz) xMax += sz alist.append(sz) %o A322108 if t.heading() == 90: t.forward(sz) yMax += sz alist.append(sz) %o A322108 if t.heading() == 180: t.forward(sz) xMin -= sz alist.append(sz) %o A322108 if t.heading() == 270: t.forward(sz) yMin -= sz alist.append(sz) %o A322108 if j > 1: %o A322108 t.color("black") %o A322108 if t.heading() == 0: alist.append(int(t.distance(xMax + sz, t.ycor()))) t.goto(xMax + sz, t.ycor()) xMax = t.xcor() %o A322108 if t.heading() == 90: alist.append(int(t.distance(t.xcor(), yMax + sz))) t.goto(t.xcor(), yMax + sz) yMax = t.ycor() %o A322108 if t.heading() == 180: alist.append(int(t.distance(xMin - sz, t.ycor()))) t.goto(xMin - sz, t.ycor()) xMin = t.xcor() %o A322108 if t.heading() == 270: alist.append(int(t.distance(t.xcor(), yMin - sz))) t.goto(t.xcor(), yMin - sz) yMin = t.ycor() %o A322108 j += 1 %o A322108 total = sum(alist)/sz blist.append(total) total = 0 del alist[:] %o A322108 j = 1 %o A322108 print(blist) %K A322108 nonn %O A322108 1,2 %A A322108 _Drew Edgette_, Nov 26 2018