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.

A329068 a(1) = 1; thereafter if the sum of digits of all previous terms up to a(n) is even then a(n+1) = (sum of digits of all previous terms)/2, otherwise a(n+1) = (sum of digits of all previous terms)*3 + 1.

This page as a plain text file.
%I A329068 #39 Nov 13 2022 02:04:01
%S A329068 1,4,16,6,9,82,112,124,24,27,190,220,232,42,45,298,59,66,72,460,490,
%T A329068 88,96,622,652,115,712,742,130,132,135,838,149,156,162,1000,167,174,
%U A329068 180,1108,1138,196,204,207,1270,1300,1312,222,225,1378,239,246,252,1540,1570,268,276
%N A329068 a(1) = 1; thereafter if the sum of digits of all previous terms up to a(n) is even then a(n+1) = (sum of digits of all previous terms)/2, otherwise a(n+1) = (sum of digits of all previous terms)*3 + 1.
%H A329068 Bence BernĂ¡th, <a href="/A329068/b329068.txt">Table of n, a(n) for n = 1..100001</a>
%o A329068 (MATLAB)
%o A329068 clear all;
%o A329068 length_seq=10000;
%o A329068 sequence(1)=1;
%o A329068 seq_for_digits(1)=sequence(1);
%o A329068 for i1=1:1:length_seq
%o A329068    if  0==mod(sum(seq_for_digits),2)
%o A329068         sequence(i1+1)=sum(seq_for_digits)/2;
%o A329068    else
%o A329068      sequence(i1+1)=sum(seq_for_digits)*3+1;
%o A329068    end
%o A329068      append=num2str(sequence(i1+1))-'0';
%o A329068      seq_for_digits=[seq_for_digits append];
%o A329068 end
%o A329068 result=transpose(sequence);
%o A329068 (PARI) lista(nn) = {va = vector(nn); va[1] = 1; sd = sumdigits(va[1]); for (n=2, nn, if (sd % 2, va[n] = 3*sd+1, va[n] = sd/2); sd += sumdigits(va[n]);); va;} \\ _Michel Marcus_, Nov 04 2019
%o A329068 (Python)
%o A329068 from itertools import islice
%o A329068 def agen(): # generator of terms
%o A329068     sd, an = 0, 1
%o A329068     while True:
%o A329068         yield an
%o A329068         sd += sum(map(int, str(an)))
%o A329068         an = 3*sd+1 if sd&1 else sd//2
%o A329068 print(list(islice(agen(), 60))) # _Michael S. Branicky_, Nov 12 2022
%Y A329068 Cf. A105801, A004207.
%K A329068 nonn,base
%O A329068 1,2
%A A329068 _Bence BernĂ¡th_, Nov 03 2019