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.

A320020 Numbers whose Collatz trajectory always alternates between a halving and a tripling step until a power of 2 is reached.

This page as a plain text file.
%I A320020 #54 May 30 2022 16:33:53
%S A320020 1,2,3,4,5,6,8,10,16,21,32,42,64,85,128,151,170,227,256,302,341,454,
%T A320020 512,682,1024,1365,2048,2730,4096,5461,8192,10922,14563,16384,21845,
%U A320020 29126,32768,43690,65536,87381,131072,174762,262144,349525,524288,699050,932067
%N A320020 Numbers whose Collatz trajectory always alternates between a halving and a tripling step until a power of 2 is reached.
%C A320020 Any number whose Collatz trajectory has two or more consecutive halving steps (before reaching a power of 2) is not included in this sequence.
%C A320020 The b-file was generated using the reverse Collatz algorithm.
%C A320020 Instead of going: n -> 3n + 1 (if odd), n/2 (if even), this algorithm starts from a power of 2 and goes: n -> (n - 1)/3 (if possible) and n*2, repeating these two consecutive steps as long as the number n is divisible by 3. The results are progressively added to a dynamic array, which gets sorted by ascending order once the algorithm terminates.
%C A320020 Example 1: 8 -> (8 - 1) and the calculation stops because 7 isn't divisible by 3. No numbers are added to the dynamic array.
%C A320020 Example 2: 16 -> (16 - 1)/3 = 5; 5*2 = 10; (10 - 1)/3 = 3; 3*2 = 6; (6 - 1) and the calculation stops because 5 isn't divisible by 3. The numbers 5, 10, 3, 6 are then added to the dynamic array.
%C A320020 Example 3: 64 -> (64 - 1)/3 = 21; 21*2 = 42; (42 - 1) and the calculation stops because 41 isn't divisible by 3. The numbers 21 and 42 are then added to the dynamic array.
%H A320020 Alessandro Polcini, <a href="/A320020/b320020.txt">Table of n, a(n) for n = 1..1000</a>
%H A320020 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%e A320020 6 is in the sequence because 6/2 = 3 (halving step); 3*3 + 1 = 10 (tripling step); 10/2 = 5 (halving step); 5*3 + 1 = 16 (tripling step) and a power of 2 is reached.
%e A320020 7 is not in this sequence because 7*3 + 1 = 22 (tripling step); 22/2 = 11 (halving step); 11*3 + 1 = 34 (tripling step); 34/2 = 17 (halving step); 17*3 + 1 = 52 (tripling step); 52/2 = 26 (halving step); 26/2 = 13 (another halving step).
%o A320020 (PARI) isp2(n) = (n==1) || (n==2) || (ispower(n,,&p) && (p==2));
%o A320020 isok(n) = {while (! isp2(n), if (n % 2, newn = (3*n+1), newn = n/2); if (((n % 2) == (newn % 2)), return (0)); n = newn;); return (1);} \\ _Michel Marcus_, Oct 07 2018
%o A320020 (Java) for(BigInteger pow = TWO; pow.compareTo(END) < 0; pow = pow.multiply(TWO)) {
%o A320020     terms.add(pow); //otherwise numbers like 8, 32, 128, etc. aren't added
%o A320020     BigInteger newPow = pow.subtract(ONE);
%o A320020     while(newPow.mod(THREE).compareTo(ZERO) == 0) {
%o A320020         terms.add(newPow.add(ONE));
%o A320020         newPow = newPow.divide(THREE);
%o A320020         terms.add(newPow);
%o A320020         newPow = newPow.add(newPow);
%o A320020         terms.add(newPow);
%o A320020         newPow = newPow.subtract(ONE);
%o A320020     }
%o A320020 }
%o A320020 terms.sort(Comparator.naturalOrder()); //sorting by ascending order
%o A320020 for(int i = 1; i < terms.size(); i++) {
%o A320020     if(terms.get(i).compareTo(terms.get(i - 1)) == 0) {
%o A320020         terms.remove(i); //to remove duplicates
%o A320020     }
%o A320020 }
%Y A320020 Cf. A006577.
%K A320020 nonn
%O A320020 1,2
%A A320020 _Alessandro Polcini_, Oct 03 2018