Sunday, October 18, 2009

1-9 again

Find the smallest prime number that contains each digit from 1 to 9
at least once.

7 Comments:

Anonymous Cry Wolf said...

Hmm...

I've got 1123468597

I'm not sure if it's correct, but I can definitely prove the number must have 10 digits :)

October 18, 2009 5:20 PM  
Blogger Ragknot said...

Cry Wolf,

1,123,468,597 is a prime, but it's not the correct answer.

October 18, 2009 6:12 PM  
Blogger Ragknot said...

HINT

Cry Wolf left some info that should be helpful

He said it will have ten digits.
He said 1,123,468,597.

I said that was a prime number, but it wasn't the answer.

You should deduce that the answer is less than 1,123,468,597.

With very little effort you should
deduce it is greater than 1,123,456,789.

I will tell you that between these two numbers there are only 579 primes.

October 18, 2009 9:22 PM  
Anonymous Cry Wolf said...

Guess #2

1123465789

October 18, 2009 10:00 PM  
Blogger Ragknot said...

Cry Wolf,

Correct, did you compute it, or find it somewhere?

October 18, 2009 10:13 PM  
Anonymous Cry Wolf said...

All I used was my calculator which is essentially a TI-89 with a qwerty keyboard to factor numbers.

I knew it had to be exactly 10 numbers, and that it had to be greater than 1123456789, so I just tried factoring combinations in ascending order, rearranging the digits, like so:

1123456789
1123456798
1123456879
1123456897
1123456978
1123456987
1123457689
1123457698
etc.

Of course, when I was actually testing the numbers I didn't check the ones ending with an even digit, but I just displayed it like that to show my method. Apparently, though... I missed the answer my first time around... oh well.

However, that's not to say I didn't try to find the answer on google :P

October 18, 2009 10:30 PM  
Blogger Ragknot said...

Very interesting.
I used Excel and an excellent basic function I found a long time ago.
Like you, I knew it was larger than 1123456789, so began there.

I found it very quickly.


'Feb 2000 by Marc Kummel aka Treebeard.
'Contact mkummel@rain.org, 'http://www.rain.org/~mkummel/

Public Function IsPrime(num As Long) As Boolean
Dim fac, dfac, maxfac As Long
'Return true if num is prime
If num = 1 Then IsPrime = False: Exit Sub 'added by ragknot
If num Mod 2 = 0 Then
fac = 2
ElseIf num Mod 3 = 0 Then
fac = 3
Else
maxfac = Int(Sqr(num))
fac = 5
dfac = 2
Do
If num Mod fac = 0 Then Exit Do
fac = fac + dfac
dfac = 6 - dfac
If fac > maxfac Then fac = num: Exit Do
Loop
End If
IsPrime = (num = fac)
End Function

October 18, 2009 11:26 PM  

Post a Comment

Links to this post:

Create a Link

<< Home