|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (8 bit)
Join Date: Jun 2003
Location: Overland Park, KS
Posts: 168
|
math riddle
you are asked you to find out how many eight digit numbers there are that contain all numbers one to eight.
( I know the answer to this part) (what I need to know is this next part) Now with the number you generated, you need to do the following. Find the sum of all the values that are divisable by 13 I am confused as to what this question is asking. |
|
|
|
|
|
#2 |
|
Red-eyed Moderator
Staff
Premium Member
Join Date: Dec 1999
Location: Regina, Saskatchewan, Canada
Posts: 17,525
|
Simple... you know the first part.. creating the 8 digit number containing all numbers 1 to 8... now you find which ones of those are divisible by 13, obviously, not all of them will be... then, create the sum of only those numbers... the first part is easy enough.. there are 40,320 combinations... but for the life of me right now, I don't remember how to figure out the second part.
__________________
-At Ford, quality is job #1, job #2 is making them explode. ~Norm MacDonald, SNL News -Switching to Glide..Balancing in my head..inside of me... taking the glide path instead. Last edited by HAL9000; 07-10-2008 at 12:44 PM. |
|
|
|
|
|
#3 |
|
Member (8 bit)
Join Date: Jun 2003
Location: Overland Park, KS
Posts: 168
|
ok,
Lets say that there are two numbers out of the 40320 that are divisible by 13 would the sum be 2 or would it be these 2 numbers added together? for example 12345678 + 23456781 = 35,802,459 |
|
|
|
|
|
#4 |
|
Red-eyed Moderator
Staff
Premium Member
Join Date: Dec 1999
Location: Regina, Saskatchewan, Canada
Posts: 17,525
|
It would be the sum added together as per your example.
|
|
|
|
|
|
#5 |
|
Member (8 bit)
Join Date: Jun 2003
Location: Overland Park, KS
Posts: 168
|
I have solved the problem!
With a little help from Excel and a couple of macros it was no problem. |
|
|
|
|
|
#6 |
|
Member (1 bit)
Join Date: Jul 2008
Posts: 0
|
|
|
|
|
|
|
#7 |
|
Member (1 bit)
Join Date: Jul 2008
Posts: 0
|
well what was the solution u came up with?
|
|
|
|
|
|
#8 |
|
Member (1 bit)
Join Date: Jul 2008
Posts: 0
|
hell i didnt even get the first part much less the second.
|
|
|
|
|
|
#9 |
|
Member (1 bit)
Join Date: Jul 2008
Posts: 0
|
yay. i finaly managed to get the 4320 that everyone else got long ago!!!
ok so now how do you do the second part please explain. |
|
|
|
|
|
#10 |
|
Member (1 bit)
Join Date: Jul 2008
Posts: 0
|
Hey kasturi, I have a list of numbers but I've found over 100 answers, When I add them in Excel i get a number in scientific notation, how many digits was ur answer?
|
|
|
|
|
|
#11 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
1) 8! = 40320
2) Pseudo code (C/Java/VB syntax mix): Code:
function Div13Sum(integer ValueToTest) returns integer {
//does the value have 8 digits?
if ( ValueToTest < 9999999 ) {
//value has less than 8 digits, do not evaluate at this level
//append 1 through 8 onto the end and test again
for ( i = 1 to 8 ) {
total = total + Div13Sum( (ValueToTest * 10) + i )
}
//return the accumulated total
return total
} else {
//value has 8 digits, is it divisible by 13?
if ( ValueToTest MOD 13 = 0 ) {
//yes it is, return the value
return ValueToTest
} else {
//no it is not, ignore this value
return 0
}
}
}
answer = Div13Sum(0)
|
|
|
|
|
|
#12 |
|
Member (1 bit)
Join Date: Jul 2008
Posts: 0
|
How do you run that code? If u can use notepad then what file extention?
|
|
|
|
|
|
#13 | |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Quote:
I just posted it because others were asking how to calculate the value. The algorithm I posted is just to show an example of how the code would look if you were to write a program. |
|
|
|
|
|
|
#14 |
|
Member (8 bit)
Join Date: Jun 2003
Location: Overland Park, KS
Posts: 168
|
Here's the macro and a fomula that I used
Macro Dim CurrentRow Sub GetString() Dim InString As String InString = InputBox("Enter text to permute:") If Len(InString) < 2 Then Exit Sub If Len(InString) >= 9 Then MsgBox "Too many permutations!" Exit Sub Else ActiveSheet.Columns(1).Clear CurrentRow = 1 Call GetPermutation("", InString) End If End Sub Sub GetPermutation(x As String, y As String) ' The source of this algorithm is unknown Dim i As Integer, j As Integer j = Len(y) If j < 2 Then Cells(CurrentRow, 1) = x & y CurrentRow = CurrentRow + 1 Else For i = 1 To j Call GetPermutation(x + Mid(y, i, 1), _ Left(y, i - 1) + Right(y, j - i)) Next End If End Sub formula =IF(MOD(A1,b1)=0,"Divisible","Non-Divisible") |
|
|
|
|
|
#15 | |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Quote:
You can paste this code into an Excel macro/VB window and run it to get the answer (this is the VBA "translation" for the pseudo-code I posted earlier): Code:
Sub GetAnswer()
Cells(1, 1).Value = Div13Sum(0)
End Sub
Function Div13Sum(ByVal ValueToTest As Long) As Double
If ValueToTest < 999999 Then
For i = 1 To 8
Div13Sum = Div13Sum + Div13Sum((ValueToTest * 10) + i)
Next
Else
If ValueToTest Mod 13 = 0 Then
Div13Sum = ValueToTest
Else
Div13Sum = 0
End If
End If
End Function
|
|
|
|
|
|
|
#16 |
|
Member (1 bit)
Join Date: Jul 2008
Posts: 0
|
Faulkner, your answer makes no sense, there is no way there are over 32,000 answers. What did it give you katsuri?
|
|
|
|
|
|
#17 |
|
Member (8 bit)
Join Date: Jun 2003
Location: Overland Park, KS
Posts: 168
|
there are 40320 different combinations of 12345678
Out of those there are 3112 that are divisible by 13. |
|
|
|
|
|
#18 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
|
|
|
|
|
|
#19 |
|
Member (1 bit)
Join Date: Jul 2008
Posts: 0
|
I figured it was something of the like... do you know how to fix it? I'm pretty curious about this thing and I'm not too good with VB.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Math | Hi Ho | General Discussion | 30 | 02-18-2006 10:12 PM |
| finding the root of a math function | hobey19 | Web Design / Development | 1 | 02-29-2004 11:35 PM |
| Looking for a good math graphing tool | Iman74 | General Discussion | 3 | 09-29-2003 12:46 PM |
| Got a LOTR riddle for you. | TimPoet | General Discussion | 45 | 01-16-2003 01:53 AM |
| Math | Colonel Sanders | General Discussion | 57 | 03-07-2002 11:18 PM |