Carmichael number, more or less

A quick-and-dirty R resolution of a riddle from The Riddler, namely to find a Carmichael number of the form abcabc:

library(numbers)
for(i in 1:9)
  for(j in 0:9)
    for(k in 0:9){
      x=i*100100+j*1010+k*101
      if(!isPrime(x)){
        p=primeFactors(x)
        if((prod(apply(outer(p,p,F="=="),1,sum)%%2))&
          (!max((x-1)%%(p-1))))break()}}

resulting into the number 101 101, since its prime factors are

> primeFactors(101101)
[1]   7  11  13 101

and 6, 10, 12, and 100 are divisors of 101100:

> primeFactors(101100) 
[1] 2 2 3 5 5 337

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: