login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A330674 Lexicographically earliest infinite sequence of distinct nonnegative terms such that a(n+1) is obtained by adding to a(n) the odd digits of a(n) and subtracting the even ones. 1
1, 2, 0, 3, 6, 4, 5, 10, 11, 13, 17, 25, 28, 18, 7, 14, 8, 9, 12, 15, 21, 20, 16, 19, 29, 36, 33, 39, 51, 57, 69, 72, 77, 91, 101, 103, 107, 115, 122, 119, 130, 134, 22, 23, 24, 26, 27, 32, 30, 31, 35, 43, 42, 34, 37, 47, 50, 55, 65, 64, 54, 38, 40, 41, 44, 45, 46, 48, 49, 52, 53, 61, 56, 58, 59, 73, 83, 78 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
When an iteration reproduces a term already in the sequence, we cancel this iteration and restart the sequence from there with the smallest integer not yet present in the sequence.
LINKS
EXAMPLE
As a(1) = 1, we get a(2) = 2 by adding the odd digit 1 to a(1);
as a(2) = 2, we get a(3) = 0 by subtracting the even digit 2 from a(2);
as a(3) = 0, we stop to iterate (0 would produce 0, already in the sequence) and restart the sequence with a(4) = 3, the smallest integer not present;
as a(4) = 3, we get a(5) = 6 by adding the odd digit 3 to a(4);
as a(5) = 6, we stop to iterate (6-6 produces 0, already in the sequence) and restart the sequence with a(6) = 4, the smallest integer not present;
as a(6) = 4, we stop to iterate (4-4 produces 0, already in the sequence) and restart the sequence with a(7) = 5, the smallest integer not present;
as a(7) = 5, we get a(8) = 10 by adding the odd digit 5 to a(7);
as a(8) = 10, we get a(9) = 11 by adding the odd digit 1 to a(8);
as a(9) = 11, we get a(10) = 13 by adding the odd digits 1 and 1 to a(9); etc.
MATHEMATICA
Nest[Append[#1, If[FreeQ[#1, #2], #2, Block[{k = 3}, While[! FreeQ[#1, k], k++]; k]] & @@ {#1, #1[[-1]] + Total@ Select[#2, OddQ] - Total@ Select[#2, EvenQ]} & @@ {#, IntegerDigits@ #[[-1]]}] &, {1}, 77] (* Michael De Vlieger, Dec 24 2019 *)
CROSSREFS
Cf. A036301 (Numbers n such that sum of even digits of n equals sum of odd digits of n).
Sequence in context: A194737 A071089 A144090 * A248966 A021495 A332356
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Carole Dubois, Dec 24 2019
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 25 19:47 EDT 2024. Contains 375454 sequences. (Running on oeis4.)