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.

A297307 Given n, define the sequence x(1) = n, thereafter if x(i) is even set x(i+1) = x(i)/2, if x(i) is odd and divisible by 3, 5 or 7 set x(i+1) = 5*x(i) + 1, otherwise set x(i+1) = 3*x(i) + 1. Then a(n) is the smallest i>1 such that x(i) = 1, 5, or 553, or -1 if none of those numbers is ever reached.

This page as a plain text file.
%I A297307 #20 Feb 11 2018 20:03:32
%S A297307 4,2,6,3,7,7,22,4,19,2,10,8,5,23,19,5,8,20,16,3,9,11,17,9,39,6,12,24,
%T A297307 14,20,78,6,36,9,15,21,27,17,34,4,81,10,39,12,55,18,76,10,31,40,10,7,
%U A297307 7,13,46,25,32,15,28,21,21,79,37,7,37,37,23,10,43,16,74,22
%N A297307 Given n, define the sequence x(1) = n, thereafter if x(i) is even set x(i+1) = x(i)/2, if x(i) is odd and divisible by 3, 5 or 7 set x(i+1) = 5*x(i) + 1, otherwise set x(i+1) = 3*x(i) + 1. Then a(n) is the smallest i>1 such that x(i) = 1, 5, or 553, or -1 if none of those numbers is ever reached.
%C A297307 (The following comments needs editing - _N. J. A. Sloane_, Feb 11 2018)
%C A297307 This is the Syracuse sequence modified by adding a constraint.
%C A297307 if x is odd and divisible by 3 or 5 or 7 then x = 5*x + 1 instead of x = 3x + 1, and x = 3*x + 1 if not divisible by 3 or 5 or 7.
%C A297307 The sequence if x even then x = x/2 and if x odd then x = 5*x + 1 diverge for n even > 12 or n odd > 5.
%C A297307 More than 1/3 of the odd numbers are divisible by 3 or 5 or 7 so this sequence will diverge or if not the Syracuse sequence will converge, it is easy to find that with the constraint added this sequence converges but with different cycles which are function of the n starting point.
%C A297307 There are 3 different cycles to end this sequence with the repetition of the cycle.
%C A297307 The main one is with a cycle of 6 values 5, 26, 13, 40, 20, 10 for 3/4 of the n values.
%C A297307 The second one is the same as the Syracuse sequence 1,4,2 for 21/100 of the n values.
%C A297307 And a third with a cycle of 175 values starting 553, 2766, 1383, 6916 ... for 3.3/100 of the n values.
%e A297307 n = 1, x(1) = 1 , x(2)= 4, x(3) = 2, x(4) = 1 so a(1) = 4.
%t A297307 With[{a = {3, 5, 7}, b = {1, 5, 553}, nn = 10^3}, Array[Length@ NestWhileList[Function[n, Which[EvenQ@ n, n/2, And[OddQ@ n, AnyTrue[a, Divisible[n, #] &]], 5 n + 1, True, 3 n + 1]], #, FreeQ[b, #] &, {2, 1}, nn] /. k_ /; k == nn + 1 -> -1 &, 72]] (* _Michael De Vlieger_, Dec 31 2017 *)
%o A297307 (BASIC)
%o A297307 For n=1 to 5000
%o A297307 i=1:x=n
%o A297307 10 i=i+1
%o A297307 If x-2*Int(x/2)=0 Then x=x/2:Goto 20
%o A297307 If x-3*Int(x/3)=0 or x-5*Int(x/5)=0 Then x=5*x+1:Goto 20
%o A297307 x=3*x+1
%o A297307 20 if x=1 or x=5 or x=553 Then Print n;i:Goto 30
%o A297307 Goto 10
%o A297307 30 Next n
%o A297307 End
%Y A297307 Cf. A006577, A297217.
%K A297307 nonn
%O A297307 1,1
%A A297307 _Pierre CAMI_, Dec 28 2017