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-3 of 3 results.

A323375 Let f(p, q) denote the pair (p + q, wt(p) + wt(q)). a(n) gives the number of iterations of f starting at (n, 1) needed to make p/q an integer, or if no integer is ever reached then a(n) = -1. (Here wt is binary weight, A000120.)

Original entry on oeis.org

1, 3, 3, 3, 1, 2, 1, 11, 4, 10, 1, 3, 4, 9, 2, 19, 1, 18, 1, 1, 7, 17, 7, 7, 6, 5, 6, 6, 1, 4, 15, 5, 16, 4, 1, 2, 4, 3, 1, 14, 3, 13, 13, 13, 12, 12, 1, 6, 12, 2, 5, 5, 11, 1, 5, 13, 10, 4, 1, 12, 3, 9, 3, 3, 1, 2, 1, 1, 40, 2, 8, 8, 39, 3, 7, 7, 9, 2, 3, 1, 3, 37, 37, 37, 5, 36, 36, 3, 1, 8
Offset: 1

Views

Author

Ctibor O. Zizka, Jan 12 2019

Keywords

Examples

			n=8; (8, 1) -> (9, 2) -> (11, 3) -> (14, 5) -> (19, 5) -> (24, 5) -> (29, 4) -> (33, 5) -> (38, 4) -> (42, 4) -> (46, 4) -> (50, 5). 50/5 = 10, so a(8) = 11 because it needs 11 iterations until p/q is an integer.
		

Crossrefs

Programs

  • PARI
    f(v) = return([v[1]+v[2], hammingweight(v[1])+hammingweight(v[2])]);
    a(n) = {my(nb = 0, v = [n, 1]); while (1, v = f(v); nb++; if (frac(v[1]/v[2]) == 0, return (nb)));} \\ Michel Marcus, Jan 13 2019

A323356 For a rational number p/q let f(p/q) = (p+q) / (A000120(p) + A000120(q)); a(n) is obtained by iterating f, starting at n/1, until an integer is reached (and then a(n) = that integer), or if no integer is ever reached then a(n) = -1.

Original entry on oeis.org

1, 2, 2, 2, 2, 2, 2, -1, 7, -1, 3, 7, 7, -1, 7, -1, 6, -1, 5, 7, 7, -1, -1, -1, -1, 8, -1, -1, 6, 8, -1, 8, 11, 8, 9, 8, -1, 8, 8, 11, -1, 11, 11, 11, -1, 11, 8, -1, 8, 11, -1, -1, 11, 11, 8, 16, -1, 15, 10, 16, -1, -1, 15, 14, 22, 14, 17, 23, 11, 15, 11, 11, 8, 12, 11, 11, 16, 12, 11
Offset: 1

Views

Author

Ctibor O. Zizka, Jan 18 2019

Keywords

Examples

			13/1 -> 14/4=7/2 -> 9/4 -> 13/3 -> 16/5 -> 21/3 = 7 so a(13) = 7.
8/1 -> 9/2 -> 11/3 -> 14/5 -> 19/5 -> 24/5 -> 29/4 -> 33/5 -> 38/4=19/2 -> 21/4 -> 25/4 -> 29/4 and the 5-cycle repeats, so a(8) = -1.
		

Crossrefs

Programs

  • Mathematica
    Array[SelectFirst[Rest@ NestWhileList[(#1 + #2)/(DigitCount[#1, 2, 1] + DigitCount[#2, 2, 1]) & @@ {Numerator@ #, Denominator@ #} &, #, UnsameQ, All], IntegerQ] /. k_ /; MissingQ@ k -> -1 &, 79] (* Michael De Vlieger, Jan 18 2019 *)

A323596 Number of (positive) iterations of f to reach an integer when starting from n/1. If no integer is ever reached then a(n) = -1. f(p/q) = (p + q) / (A000120(p) + A000120(q)).

Original entry on oeis.org

1, 3, 3, 3, 1, 2, 1, -1, 4, -1, 1, 3, 5, -1, 2, -1, 1, -1, 1, 1, 4, -1, -1, -1, -1, 5, -1, -1, 1, 4, -1, 5, 16, 4, 1, 2, -1, 3, 1, 14, -1, 13, 13, 13, -1, 12, 1, -1, 6, 2, -1, -1, 11, 1, 5, 13, -1, 4, 1, 12, -1, -1, 3, 3, 1, 2, 1, 1, 16, 2, 8, 8, 4, 3, 7, 7, 9, 2, 14
Offset: 1

Views

Author

Ctibor O. Zizka, Jan 18 2019

Keywords

Examples

			8/1 -> 9/2 -> 11/3 -> 14/5 -> 19/5 -> 24/5 -> 29/4 -> 33/5 -> 38/4=19/2 -> 21/4 -> 25/4 -> 29/4 and the 5-cycle repeats, so a(8) = -1.
13/1 -> 14/4=7/2 -> 9/4 -> 13/3 -> 16/5 -> 21/3=7 so a(13) = 5.
		

Crossrefs

Programs

  • Mathematica
    Array[If[AnyTrue[#, IntegerQ], 1 + LengthWhile[#, ! IntegerQ@ # &], -1] &@ Rest@ NestWhileList[(#1 + #2)/(DigitCount[#1, 2, 1] + DigitCount[#2, 2, 1]) & @@ {Numerator@ #, Denominator@ #} &, #, UnsameQ, All] &, 79] (* Michael De Vlieger, Jan 18 2019 *)
Showing 1-3 of 3 results.