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.

A359803 a(1) = 1; for n > 1, a(n) = n-1 if a(n-1) = 1, otherwise, apply the '3x+1' function to a(n-1).

This page as a plain text file.
%I A359803 #94 Jun 02 2025 15:26:34
%S A359803 1,1,2,1,4,2,1,7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,24,12,6,3,
%T A359803 10,5,16,8,4,2,1,35,106,53,160,80,40,20,10,5,16,8,4,2,1,49,148,74,37,
%U A359803 112,56,28,14,7,22,11,34,17,52,26,13,40,20,10,5,16,8
%N A359803 a(1) = 1; for n > 1, a(n) = n-1 if a(n-1) = 1, otherwise, apply the '3x+1' function to a(n-1).
%e A359803 For n = 5, the sequence so far is (1, 1, 2, 1) a(4) = 1, therefore a(5) = 5-1 = 4.
%e A359803 For n = 6, the sequence so far is (1, 1, 2, 1, 4), 4 is not 1, so we apply the '3x+1' function, 4 is even, so we divide it by 2, therefore a(6) = 4/2 = 2.
%e A359803 For n = 9, the sequence so far is (1, 1, 2, 1, 4, 2, 1, 7), 7 is not 1, so we apply the '3x+1' function, 7 is odd, so we multiply it by 3 and add 1, therefore a(9) = 3*(7)+1 = 22.
%o A359803 (Python)
%o A359803 def a(length):
%o A359803     sequence = [1]
%o A359803     while len(sequence) < length:
%o A359803         last_term = sequence[-1]
%o A359803         if last_term == 1:
%o A359803             next_term = len(sequence)
%o A359803         elif last_term % 2 == 0:
%o A359803             next_term = last_term // 2
%o A359803         else:
%o A359803             next_term = 3 * last_term + 1
%o A359803         sequence.append(next_term)
%o A359803     return sequence
%Y A359803 Selected rows from A070165.
%Y A359803 Cf. A014682.
%K A359803 nonn,look,easy
%O A359803 1,3
%A A359803 _Wagner Martins_, Jul 17 2023