login
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.
1
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, 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, 4891, 2, 1, 46, 1, 2, 3, 2, 3, 4, 3, 2, 9, 6, 1, 4, 1, 4, 1, 4, 27
OFFSET
1,3
COMMENTS
At least one iteration must be made.
Corresponding primes: 2, 5, 23, 11, 41, 17, 59, 23, 6197, 29, 68891, 311, 113, 41, 131, 47, 149, 53, 167, 59, ...
EXAMPLE
n=3: 3 => 8 => 23, so a(3)=2.
n=9: 9 => 26 => 77 => 230 => 689 => 2066 => 6197, so a(9)=6.
PROG
(Java)
import java.math.BigInteger;
public class A215136 {
public static void main (String[] args) {
long n, t, step;
BigInteger BI1 = BigInteger.valueOf(1);
BigInteger BI3 = BigInteger.valueOf(3);
for (n=1; n<3333; ++n) {
BigInteger bn = BigInteger.valueOf(n);
t = n;
for (step=1; step<9999; ++step) {
bn = bn.multiply(BI3).subtract(BI1);
t = (t*3+614889782588491409L) % 614889782588491410L; // A002110(15)
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) ) {
if (bn.isProbablePrime(2)) {
if (bn.isProbablePrime(80)) break;
}
}
}
if (step==9999) System.out.printf("---(%d), ", n);
else System.out.printf("%d, ", step);
}
}
}
CROSSREFS
Sequence in context: A144757 A372835 A363520 * A318658 A318512 A295310
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Aug 04 2012
STATUS
approved