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.

Showing 1-4 of 4 results.

A065186 a(1)=1, a(2)=3, a(3)=5, a(4)=2, a(5)=4; for n > 5, a(n) = a(n-5) + 5.

Original entry on oeis.org

1, 3, 5, 2, 4, 6, 8, 10, 7, 9, 11, 13, 15, 12, 14, 16, 18, 20, 17, 19, 21, 23, 25, 22, 24, 26, 28, 30, 27, 29, 31, 33, 35, 32, 34, 36, 38, 40, 37, 39, 41, 43, 45, 42, 44, 46, 48, 50, 47, 49, 51, 53, 55, 52, 54, 56, 58, 60, 57, 59, 61, 63, 65, 62, 64, 66, 68, 70, 67, 69, 71, 73
Offset: 1

Views

Author

Antti Karttunen, Oct 19 2001

Keywords

Comments

"Greedy Dragons" permutation of the natural numbers, inverse of A065187.
This permutation is produced by a simple greedy algorithm: walk along each successive antidiagonal of an infinite array and place a Shoogi dragon piece (i.e., the "promoted" rook, Ryuu, that moves like a chess rook, but can also move one square diagonally) in the first available position where it is not threatened by any dragon already placed.
I.e., this permutation satisfies the condition that p(i+1) != p(i)+-1 for all i.
Alternatively, this is obtained directly if n-1 is converted to base 5, the least significant digit is doubled (modulo 5, i.e., 0->0, 1->2, 2->4, 3->1, 4->3) and one is added back to the resulting number.
a(1) = 1, a(n) = smallest number such that no two successive terms differ by 1 and no two terms are equal. - Amarnath Murthy, May 06 2003
This is also the lexicographic first positive sequence such that the distance between any subsequent terms, |a(n+1)-a(n)|, is a prime number and no number occurs twice, with a(1) = 1: A variant of A277618, which obeys the same rules but starts with a(0) = 0; and of A277617, which is defined similarly with squares > 1 instead of primes. - M. F. Hasler, Oct 23 2016

Crossrefs

"Greedy Queens" and "Quintal Queens" permutations: A065188, A065257.
Cf. A065186.

Programs

  • Maple
    [seq(GreedyDragonsDirect(j),j=1..125)]; GreedyDragonsDirect := n -> n + ((n-1) mod 5) - 5*(floor((n-1 mod 5)/3));
    Or empirically, by using the algorithm given at A065188: GreedyDragons := upto_n -> PM2PL(GreedyNonThreateningPermutation(upto_n,1,1),upto_n);
  • Mathematica
    RecurrenceTable[{a[1] == 1, a[2] == 3, a[3] == 5, a[4] == 2, a[5] == 4, a[n] == a[n - 5] + 5}, a, {n, 80}] (* or *) LinearRecurrence[{1, 0, 0, 0, 1, -1}, {1, 3, 5, 2, 4, 6}, 80] (* Harvey P. Dale, Mar 11 2012 *)
    Flatten[Table[5n + {1, 3, 5, 2, 4}, {n, 0, 14}]] (* Alonso del Arte, Jul 25 2017 *)
  • PARI
    { for (n=1, 1000, if (n>5, a=a5 + 5; a5=a4; a4=a3; a3=a2; a2=a1; a1=a, if (n==1, a=a5=1, if (n==2, a=a4=3, if (n==3, a=a3=5, if (n==4, a=a2=2, a=a1=4))))); write("b065186.txt", n, " ", a) ) } \\ Harry J. Smith, Oct 13 2009
    
  • PARI
    n=1;v=[n];while(n<200,if(isprime(abs(n-v[#v]))&&!vecsearch(vecsort(v),n),v=concat(v,n);n=1);n++);v \\ Derek Orr, Jul 24 2017
    
  • PARI
    a(n) = n--; [1,3,5,2,4][n%5+1]+5*(n\5) \\ David A. Corneth, Jul 24 2017
    
  • PARI
    first(n) = my(v = [1,3,5,2,4]); if(n < 5, return(vector(n, i, v[i])), v = concat(v, vector(n-5))); for(i=6, n, v[i]=5 + v[i-5]); v \\ David A. Corneth, Jul 24 2017
    
  • PARI
    nxt(n) = if(n%5, n+2, n-3) \\ David A. Corneth, Jul 24 2017

Formula

a(n) = n + ((n-1) mod 5) - 5*(floor(((n-1) mod 5)/3)).
G.f.: x*(x^5 + 2*x^4 - 3*x^3 + 2*x^2 + 2*x + 1)/((x - 1)*(x^5 - 1))
a(n) = a(n-1) + a(n-5) - a(n-6), with n>6, a(1)=1, a(2)=3, a(3)=5, a(4)=2, a(5)=4, a(6)=6. - Harvey P. Dale, Mar 11 2012

A065256 Quintal Queens permutation of N: halve or multiply by 3 (mod 5) each digit (0->0, 1->3, 2->1, 3->4, 4->2) of the base 5 representation of n.

Original entry on oeis.org

0, 3, 1, 4, 2, 15, 18, 16, 19, 17, 5, 8, 6, 9, 7, 20, 23, 21, 24, 22, 10, 13, 11, 14, 12, 75, 78, 76, 79, 77, 90, 93, 91, 94, 92, 80, 83, 81, 84, 82, 95, 98, 96, 99, 97, 85, 88, 86, 89, 87, 25, 28, 26, 29, 27, 40, 43, 41, 44, 42, 30, 33, 31, 34, 32, 45, 48, 46, 49, 47, 35, 38
Offset: 0

Views

Author

Antti Karttunen, Oct 26 2001

Keywords

Comments

All the permutations A004515 and A065256-A065258 consist of the first fixed term ("Queen on the corner") plus infinitely many 4-cycles and they satisfy the "nonattacking queen condition" that p(i+d) <> p(i)+-d for all i and d >= 1.
The corresponding infinite permutation matrix is a scale-invariant fractal (cf. A048647) and any subarray (5^i) X (5^i) (i >= 1) cut from its corner gives a solution to the case n=5^i of the n nonattacking queens on n X n chessboard (A000170). Is there any permutation of N which would give solutions to the queen problem with more frequent intervals than A000351?

Crossrefs

Inverse permutation: A004515. A065256[n] = A065258[n+1]-1. Cf. also A065187, A065189.

Programs

  • Maple
    [seq(QuintalQueens0Inv(j),j=0..124)];
    HalveDigit := (d,b) -> op(2,op(1,msolve(2*x=d,b))); # b should be an odd integer >= 3 and d should be in range [0,b-1].
    HalveDigits := proc(n,b) local i; add((b^i)*HalveDigit((floor(n/(b^i)) mod b),b),i=0..floor(evalf(log[b](n+1)))+1); end;
    QuintalQueens0Inv := n -> HalveDigits(n,5);
  • Mathematica
    HalveDigit[d_, b_ /; OddQ[b] && b >= 3] /; 0 <= d <= b - 1 := Module[{x}, x /. Solve[2*x == d, x, Modulus -> b][[1]]];
    HalveDigits[n_, b_] := Sum[b^i*HalveDigit[Mod[Floor[n/b^i] , b], b], {i, 0, Floor[Log[b, n + 1]]}];
    QuintalQueens0Inv[n_] := HalveDigits[n, 5];
    Table[QuintalQueens0Inv[n], {n, 0, 80}] (* Jean-François Alcover, Mar 05 2016, adapted from Maple *)

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A065258 Quintal Queens permutation of N: halve or multiply by 3 (mod 5) each digit (0->0, 1->3, 2->1, 3->4, 4->2) of the base 5 representation of n-1, add one.

Original entry on oeis.org

1, 4, 2, 5, 3, 16, 19, 17, 20, 18, 6, 9, 7, 10, 8, 21, 24, 22, 25, 23, 11, 14, 12, 15, 13, 76, 79, 77, 80, 78, 91, 94, 92, 95, 93, 81, 84, 82, 85, 83, 96, 99, 97, 100, 98, 86, 89, 87, 90, 88, 26, 29, 27, 30, 28, 41, 44, 42, 45, 43, 31, 34, 32, 35, 33, 46, 49, 47, 50, 48, 36, 39
Offset: 1

Views

Author

Antti Karttunen, Oct 26 2001

Keywords

Comments

See comment at A065256.

Crossrefs

Inverse permutation: A065257. A065258[n] = A065256[n-1]+1. Cf. also A065187, A065189.

A167046 Angry numbers: each number n must be more than n places from n-1 and n+1. This sequence places each number as early as possible.

Original entry on oeis.org

1, 4, 7, 2, 10, 13, 16, 3, 5, 19, 22, 8, 25, 28, 31, 6, 11, 34, 37, 40, 14, 9, 43, 46, 17, 49, 52, 55, 58, 12, 20, 61, 64, 67, 23, 70, 15, 73, 76, 26, 79, 82, 85, 18, 29, 88, 91, 32, 94, 97, 100, 103, 21, 35, 106, 109, 112, 38, 115, 24, 118, 41, 121, 124, 127, 130, 133, 27
Offset: 1

Views

Author

Keywords

Comments

This sequence is a permutation of the positive integers. After any two increases in the position of n from after the first hole, it will be possible to put the next number in that hole.

Examples

			For a(n) = 2, n must be at least 3 away from a^{-1}(1) = 1, so n = 4. Next, a(n) = 3 must be 4 away from 4, so it can't be less than 4; hence a(8) = 3. Then a(n) = 4 must be 5 away from 8; the first hole at 2 is far enough, so a(2) = 4.
		

Crossrefs

Programs

  • PARI
    dist(n) = n+1
    al(n) = {local(d,v,w,mn,j);
    v=vector(n);w=vector(n);
    v[1]=w[1]=1;mn=2;
    for(k=2,n,
    d=dist(k);
    if(w[k-1]-d>=mn,
    j=mn;mn++;while(v[mn],mn++),
    j=w[k-1]+d;while(j<=#v&v[j],j++);if(j>#v,v=vector(j,i,if(i<=#v,v[i],0))));
    v[j]=k;w[k]=j);
    v}
Showing 1-4 of 4 results.