A320020 Numbers whose Collatz trajectory always alternates between a halving and a tripling step until a power of 2 is reached.
1, 2, 3, 4, 5, 6, 8, 10, 16, 21, 32, 42, 64, 85, 128, 151, 170, 227, 256, 302, 341, 454, 512, 682, 1024, 1365, 2048, 2730, 4096, 5461, 8192, 10922, 14563, 16384, 21845, 29126, 32768, 43690, 65536, 87381, 131072, 174762, 262144, 349525, 524288, 699050, 932067
Offset: 1
Keywords
Examples
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. 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).
Links
Crossrefs
Cf. A006577.
Programs
-
Java
for(BigInteger pow = TWO; pow.compareTo(END) < 0; pow = pow.multiply(TWO)) { terms.add(pow); //otherwise numbers like 8, 32, 128, etc. aren't added BigInteger newPow = pow.subtract(ONE); while(newPow.mod(THREE).compareTo(ZERO) == 0) { terms.add(newPow.add(ONE)); newPow = newPow.divide(THREE); terms.add(newPow); newPow = newPow.add(newPow); terms.add(newPow); newPow = newPow.subtract(ONE); } } terms.sort(Comparator.naturalOrder()); //sorting by ascending order for(int i = 1; i < terms.size(); i++) { if(terms.get(i).compareTo(terms.get(i - 1)) == 0) { terms.remove(i); //to remove duplicates } }
-
PARI
isp2(n) = (n==1) || (n==2) || (ispower(n,,&p) && (p==2)); 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
Comments