All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Prime divisors (Posted on 2005-01-04)
6300846559 is such that 6 is divisible by 2; 63, by 3; 630, by 5; 6300, by 7; and, in general, if you take its first N digits, it will be divisible by the N-th prime.

There is only one other such 10 digit number: can you find it?

 See The Solution Submitted by e.g. Rating: 3.7500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Solution (VB program) | Comment 1 of 11

The only two 10 digit numbers like this are 8757193191 and 6300846559.

Not meaning to provoke any more chatterbox jokes, but the following Visual Basic program found both numbers in ZERO elapsed time:

Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
Sub Main()
Randomize()
Dim strstarttime As String
Dim strendtime As String
Dim strend As String
Dim intdigits(10) As Double
Dim dblwork As Double
strstarttime = TimeOfDay
Console.WriteLine("Start of execution: " & strstarttime)
For index1 As Integer = 2 To 9
intdigits(0) = index1
dblwork = ( _
((10 ^ 0) * intdigits(0)) _
)
If (dblwork / 2) = Fix(dblwork / 2) Then
digit_1(intdigits, dblwork)
End If
Next
strendtime = TimeOfDay
Console.WriteLine(" ")
Console.WriteLine("Start of execution: " & strstarttime)
strendtime = TimeOfDay
Console.WriteLine("End of execution: " & strendtime)
strend = "?"
Console.WriteLine(" ")
While strend <> "X"
Console.WriteLine("Please enter X to exit program...")
End While
End Sub

Sub digit_1(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(1) = index1
dblwork = ( _
((10 ^ 1) * intdigits(0)) _
+ ((10 ^ 0) * intdigits(1)) _
)
If (dblwork / 3) = Fix(dblwork / 3) Then
digit_2(intdigits, dblwork)
End If
Next
End Sub

Sub digit_2(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(2) = index1
dblwork = ( _
((10 ^ 2) * intdigits(0)) _
+ ((10 ^ 1) * intdigits(1)) _
+ ((10 ^ 0) * intdigits(2)) _
)
If (dblwork / 5) = Fix(dblwork / 5) Then
digit_3(intdigits, dblwork)
End If
Next
End Sub

Sub digit_3(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(3) = index1
dblwork = ( _
((10 ^ 3) * intdigits(0)) _
+ ((10 ^ 2) * intdigits(1)) _
+ ((10 ^ 1) * intdigits(2)) _
+ ((10 ^ 0) * intdigits(3)) _
)
If (dblwork / 7) = Fix(dblwork / 7) Then
digit_4(intdigits, dblwork)
End If
Next
End Sub

Sub digit_4(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(4) = index1
dblwork = ( _
((10 ^ 4) * intdigits(0)) _
+ ((10 ^ 3) * intdigits(1)) _
+ ((10 ^ 2) * intdigits(2)) _
+ ((10 ^ 1) * intdigits(3)) _
+ ((10 ^ 0) * intdigits(4)) _
)
If (dblwork / 11) = Fix(dblwork / 11) Then
digit_5(intdigits, dblwork)
End If
Next
End Sub

Sub digit_5(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(5) = index1
dblwork = ( _
((10 ^ 5) * intdigits(0)) _
+ ((10 ^ 4) * intdigits(1)) _
+ ((10 ^ 3) * intdigits(2)) _
+ ((10 ^ 2) * intdigits(3)) _
+ ((10 ^ 1) * intdigits(4)) _
+ ((10 ^ 0) * intdigits(5)) _
)
If (dblwork / 13) = Fix(dblwork / 13) Then
digit_6(intdigits, dblwork)
End If
Next
End Sub

Sub digit_6(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(6) = index1
dblwork = ( _
((10 ^ 6) * intdigits(0)) _
+ ((10 ^ 5) * intdigits(1)) _
+ ((10 ^ 4) * intdigits(2)) _
+ ((10 ^ 3) * intdigits(3)) _
+ ((10 ^ 2) * intdigits(4)) _
+ ((10 ^ 1) * intdigits(5)) _
+ ((10 ^ 0) * intdigits(6)) _
)
If (dblwork / 17) = Fix(dblwork / 17) Then
digit_7(intdigits, dblwork)
End If
Next
End Sub

Sub digit_7(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(7) = index1
dblwork = ( _
((10 ^ 7) * intdigits(0)) _
+ ((10 ^ 6) * intdigits(1)) _
+ ((10 ^ 5) * intdigits(2)) _
+ ((10 ^ 4) * intdigits(3)) _
+ ((10 ^ 3) * intdigits(4)) _
+ ((10 ^ 2) * intdigits(5)) _
+ ((10 ^ 1) * intdigits(6)) _
+ ((10 ^ 0) * intdigits(7)) _
)
If (dblwork / 19) = Fix(dblwork / 19) Then
digit_8(intdigits, dblwork)
End If
Next
End Sub

Sub digit_8(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(8) = index1
dblwork = ( _
((10 ^ 8) * intdigits(0)) _
+ ((10 ^ 7) * intdigits(1)) _
+ ((10 ^ 6) * intdigits(2)) _
+ ((10 ^ 5) * intdigits(3)) _
+ ((10 ^ 4) * intdigits(4)) _
+ ((10 ^ 3) * intdigits(5)) _
+ ((10 ^ 2) * intdigits(6)) _
+ ((10 ^ 1) * intdigits(7)) _
+ ((10 ^ 0) * intdigits(8)) _
)
If (dblwork / 23) = Fix(dblwork / 23) Then
digit_9(intdigits, dblwork)
End If
Next
End Sub

Sub digit_9(ByRef intdigits, ByRef dblwork)
For index1 As Integer = 0 To 9
intdigits(9) = index1
dblwork = ( _
((10 ^ 9) * intdigits(0)) _
+ ((10 ^ 8) * intdigits(1)) _
+ ((10 ^ 7) * intdigits(2)) _
+ ((10 ^ 6) * intdigits(3)) _
+ ((10 ^ 5) * intdigits(4)) _
+ ((10 ^ 4) * intdigits(5)) _
+ ((10 ^ 3) * intdigits(6)) _
+ ((10 ^ 2) * intdigits(7)) _
+ ((10 ^ 1) * intdigits(8)) _
+ ((10 ^ 0) * intdigits(9)) _
)
If (dblwork / 29) = Fix(dblwork / 29) Then
digit_10(intdigits, dblwork)
End If
Next
End Sub

Sub digit_10(ByRef intdigits, ByRef dblwork)
Console.WriteLine(dblwork)
End Sub
End Module

 Posted by Penny on 2005-01-04 15:44:05

 Search: Search body:
Forums (0)