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.

A271973 Smallest number k such that gcd(s1, s2) = n, where s1 is the sum of the odd numbers and s2 is the sum of the even numbers in the Collatz (3x+1) trajectory of k.

Original entry on oeis.org

1, 10, 9, 30, 65, 5, 74, 86, 368, 135, 970, 50, 95, 101, 1045, 178, 793, 7, 214, 196, 18, 423, 133, 200, 2572, 629, 621, 358, 700, 451, 3167, 1924, 3611, 1926, 662, 510, 6688, 437, 1525, 5072, 3724, 3161, 1034, 240, 5848, 2487, 704, 442, 19120, 1230, 5138, 3524
Offset: 1

Views

Author

Michel Lagneau, Jul 13 2016

Keywords

Examples

			a(6) = 5 because the Collatz trajectory of 5 is 5 -> 16 -> 8 -> 4 -> 2 -> 1 with s1 = 5+1 = 6 and s2 = 16+8+4+2 = 30 => gcd(6,30) = 6.
		

Crossrefs

Programs

  • Maple
    nn:=10^8:
    for n from 1 to 60 do:
    ii:=0:
      for k from 1 to nn while(ii=0) do:
       kk:=1:m:=k:T[kk]:=k:it:=0:
        for i from 1 to nn while(m<>1) do:
         if irem(m,2)=0
          then
           m:=m/2:kk:=kk+1:T[kk]:=m:
          else
          m:=3*m+1:kk:=kk+1:T[kk]:=m:
         fi:
        od:
         s1:=0:s2:=0:
          for j from 1 to kk do:
           if irem(T[j],2)=1
            then
            s1:=s1+T[j]:
            else
            s2:=s2+T[j]:
           fi:
          od:
           g:=gcd(s1,s2):
           if g=n
           then
           ii:=1:printf("%d %d \n",n,k):
           else fi:
        od:
       od:
  • Mathematica
    Table[k = 1; While[n != GCD[Total@ Select[#, OddQ], Total@ Select[#, EvenQ]] &@ NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, k, # > 1 &], k++]; k, {n, 52}] (* Michael De Vlieger, Jul 13 2016 *)