# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a215136 Showing 1-1 of 1 %I A215136 #10 Aug 05 2012 10:32:34 %S A215136 1,1,2,1,2,1,2,1,6,1,8,3,2,1,2,1,2,1,2,1,4892,47,4,1,10,5,2,1,2,1,44, %T A215136 7,2,1,2,1,4,1,2,9,12,11,2,1,2,1,2,3,4,1,4,367,4,5,2,1,2,1,12,1,12, %U A215136 4891,2,1,46,1,2,3,2,3,4,3,2,9,6,1,4,1,4,1,4,27 %N A215136 Start with n, iterate the process x -> x*3-1 until reaching a prime; then a(n) is the number of iterations required, or 0 if no prime is ever reached. %C A215136 At least one iteration must be made. %C A215136 Corresponding primes: 2, 5, 23, 11, 41, 17, 59, 23, 6197, 29, 68891, 311, 113, 41, 131, 47, 149, 53, 167, 59, ... %e A215136 n=3: 3 => 8 => 23, so a(3)=2. %e A215136 n=9: 9 => 26 => 77 => 230 => 689 => 2066 => 6197, so a(9)=6. %o A215136 (Java) %o A215136 import java.math.BigInteger; %o A215136 public class A215136 { %o A215136 public static void main (String[] args) { %o A215136 long n, t, step; %o A215136 BigInteger BI1 = BigInteger.valueOf(1); %o A215136 BigInteger BI3 = BigInteger.valueOf(3); %o A215136 for (n=1; n<3333; ++n) { %o A215136 BigInteger bn = BigInteger.valueOf(n); %o A215136 t = n; %o A215136 for (step=1; step<9999; ++step) { %o A215136 bn = bn.multiply(BI3).subtract(BI1); %o A215136 t = (t*3+614889782588491409L) % 614889782588491410L; // A002110(15) %o A215136 if (t<=47 || (t%2>0 && t%3>0 && t%5>0 && t%7>0 && t%11>0 && t%13>0 && t%17>0 && t%19>0 && t%23>0 && t%29>0 && t%31>0 && t%37>0 && t%41>0 && t%43>0 && t%47>0) ) { %o A215136 if (bn.isProbablePrime(2)) { %o A215136 if (bn.isProbablePrime(80)) break; %o A215136 } %o A215136 } %o A215136 } %o A215136 if (step==9999) System.out.printf("---(%d), ", n); %o A215136 else System.out.printf("%d, ", step); %o A215136 } %o A215136 } %o A215136 } %Y A215136 Cf. A000040, A078681. %K A215136 nonn %O A215136 1,3 %A A215136 _Alex Ratushnyak_, Aug 04 2012 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE