A335365 Numbers that are unreachable by the process of starting from 1 and adding 5 and/or multiplying by 3.
2, 4, 5, 7, 10, 12, 15, 17, 20, 22, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275, 280, 285
Offset: 1
Examples
Starting with 1, either adding 5 or multiplying by 3 results in a number greater than 2, so 2 is unreachable and therefore in the sequence. Starting with 1, multiplying by 3 gives 3, proving 3 is reachable and therefore not in the sequence.
References
- Marijn Haverbeke, Eloquent JavaScript, 3rd Ed. San Francisco (2019): No Starch, p. 51.
Links
- Colin Barker, Table of n, a(n) for n = 1..1000
- Index entries for linear recurrences with constant coefficients, signature (2,-1).
Crossrefs
Programs
-
JavaScript
// See Haverbeke (2019).
-
Mathematica
LinearRecurrence[{2,-1},{2,4,5,7,10,12,15,17,20,22,25,30},70] (* Harvey P. Dale, Apr 01 2023 *)
-
PARI
{is(n)=!(n%5&& !while(n>4, n%3|| is(n/3)|| break (n=1); n-=5)&& n%2==1)} \\ Using exhaustive search, for illustration. - M. F. Hasler, Jun 05 2020
-
PARI
select( {is(n)=n%5==0|| (n<23&&(n%5==2||n==4))}, [1..199]) \\ Much more efficient. - M. F. Hasler, Jun 05 2020
-
PARI
Vec(x*(2 - x^2 + x^3 + x^4 - x^5 + x^6 - x^7 + x^8 - x^9 + x^10 + 2*x^11) / (1 - x)^2 + O(x^50)) \\ Colin Barker, Jun 07 2020
-
Scala
// Based on Haverbeke (2019) def find153Sol(n: Int): List[Int] = { def recur153(curr: Int, history: List[Int]): List[Int] = { if (curr == n) history.drop(1) :+ n else if (curr > n) List() else { val add5Branch = recur153(curr + 5, history :+ curr) if (add5Branch.nonEmpty) add5Branch else recur153(curr * 3, history :+ curr) } } recur153(1, List(1)) } (1 to 200).filter(find153Sol(_).isEmpty)
Formula
G.f.: (2*x^11 + x^10 - x^9 + x^8 - x^7 + x^6 - x^5 + x^4 + x^3 - x^2 + 2)*x/(x - 1)^2. - Alois P. Heinz, Jun 05 2020
From Colin Barker, Jun 07 2020: (Start)
a(n) = 2*a(n-1) - a(n-2) for n>12.
a(n) = 5*(n-6) for n>10.
(End)
Comments