cp's OEIS Frontend

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.

A210841 Coordinates (x,y) of the endpoint of a structure (or curve) formed by Q-toothpicks of size = 1..n. The inflection points are the n-th nodes if n is prime.

Original entry on oeis.org

0, 0, 1, 1, 3, -1, 6, -4, 10, -8, 5, -13, -1, -19, 6, -26, 14, -34, 5, -43, -5, -33, 6, -22, 18, -10, 5, 3, -9, 17, 6, 32, 22, 16, 5, -1, -13, -19, 6, -38, 26, -58, 5, -79, -17, -57, 6, -34, 30, -10, 5, 15, -21, -11, 6, -38, 34, -10, 5, 19, -25, 49, 6, 80, 38, 112
Offset: 0

Views

Author

Omar E. Pol, Mar 29 2012

Keywords

Comments

The same idea as A210838 but here the inflection points are prime numbers.

Examples

			-------------------------------------
Stage n also              The end as
the size of     Pair      inflection
Q-toothpick   (x    y)      point
-------------------------------------
.    0         0,   0,        -
.    1         1,   1,        -
.    2         3,  -1,       Yes
.    3         6,  -4,       Yes
.    4        10,  -8,        -
.    5         5, -13,       Yes
.    6        -1, -19,        -
.    7         6, -26,       Yes
		

Crossrefs

Programs

  • Mathematica
    A210841[nmax_]:=Module[{ep={0,0},angle=3/4Pi,turn=Pi/2},Join[{ep},Table[If[!PrimeQ[n-1],If[n>6&&PrimeQ[n-2],turn*=-1];angle-=turn];ep=AngleVector[ep,{Sqrt[2]n,angle}],{n,nmax}]]];
    A210841[100] (* Generates 101 coordinate pairs *) (* Paolo Xausa, Mar 04 2023 *)
  • PARI
    A210841(nmax) = my(ep=vector(nmax+1), turn=1, ep1, ep2); ep[1]=[0, 0]; if(nmax==0, return(ep)); ep[2]=[1, 1]; for(n=2, nmax, ep1=ep[n-1]; ep2=ep[n]; if(isprime(n-1), ep[n+1]=[ep2[1]+n*sign(ep2[1]-ep1[1]), ep2[2]+n*sign(ep2[2]-ep1[2])], if(n>6 && isprime(n-2), turn*=-1); ep[n+1]=[ep2[1]-turn*n*sign(ep1[2]-ep2[2]), ep2[2]+turn*n*sign(ep1[1]-ep2[1])])); ep;
    A210841(100) \\ Generates 101 coordinate pairs - Paolo Xausa, Mar 04 2023
    
  • Python
    from numpy import sign
    from sympy import isprime
    def A210841(nmax):
        ep, turn = [(0, 0), (1, 1)], 1
        for n in range(2, nmax + 1):
            ep1, ep2 = ep[-2], ep[-1]
            if isprime(n - 1): # Continue straight
                dx = n * sign(ep2[0] - ep1[0])
                dy = n * sign(ep2[1] - ep1[1])
            else: # Turn
                if n > 6 and isprime(n - 2): turn *= -1
                dx = turn * n * sign(ep2[1] - ep1[1])
                dy = turn * n * sign(ep1[0] - ep2[0])
            ep.append((ep2[0] + dx, ep2[1] + dy))
        return ep[:nmax+1]
    print(A210841(100)) # Generates 101 coordinate pairs - Paolo Xausa, Mar 04 2023

Extensions

a(14) corrected by and more terms from Paolo Xausa, Mar 04 2023