Go Back   PCMech Forums > General & Off Topic > General Discussion

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 07-10-2008, 12:22 PM   #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.
Kasturi is offline   Reply With Quote
Old 07-10-2008, 12:36 PM   #2
Red-eyed Moderator
Staff
Premium Member
 
HAL9000's Avatar
 
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.
HAL9000 is offline   Reply With Quote
Old 07-10-2008, 01:01 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
Kasturi is offline   Reply With Quote
Old 07-10-2008, 01:14 PM   #4
Red-eyed Moderator
Staff
Premium Member
 
HAL9000's Avatar
 
Join Date: Dec 1999
Location: Regina, Saskatchewan, Canada
Posts: 17,525
It would be the sum added together as per your example.
HAL9000 is offline   Reply With Quote
Old 07-11-2008, 12:25 PM   #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.
Kasturi is offline   Reply With Quote
Old 07-11-2008, 12:49 PM   #6
Member (1 bit)
 
Join Date: Jul 2008
Posts: 0
Quote:
Originally Posted by Kasturi View Post
I have solved the problem!

With a little help from Excel and a couple of macros it was no problem.
Could you elaborate on the macros. I am curious how you worked it?
Anikara is offline   Reply With Quote
Old 07-12-2008, 03:14 PM   #7
Member (1 bit)
 
Join Date: Jul 2008
Posts: 0
well what was the solution u came up with?
m3rl1n is offline   Reply With Quote
Old 07-13-2008, 04:27 PM   #8
Member (1 bit)
 
Join Date: Jul 2008
Posts: 0
Boom

hell i didnt even get the first part much less the second.
joe17857 is offline   Reply With Quote
Old 07-14-2008, 04:01 AM   #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.
joe17857 is offline   Reply With Quote
Old 07-16-2008, 04:10 PM   #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?
alpaca9000 is offline   Reply With Quote
Old 07-16-2008, 04:33 PM   #11
Come in Ray...
 
faulkner132's Avatar
 
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)
faulkner132 is offline   Reply With Quote
Old 07-16-2008, 05:17 PM   #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?
alpaca9000 is offline   Reply With Quote
Old 07-17-2008, 11:08 AM   #13
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Quote:
Originally Posted by alpaca9000 View Post
How do you run that code? If u can use notepad then what file extention?
It's pseudo-code, so it can't be run as is. You would need to translate it to your language of choice.

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.
faulkner132 is offline   Reply With Quote
Old 07-17-2008, 11:39 AM   #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")
Kasturi is offline   Reply With Quote
Old 07-17-2008, 03:02 PM   #15
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Quote:
Originally Posted by alpaca9000 View Post
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?
There are actually over 32,000 answers... the sum of them is 806546892372

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
faulkner132 is offline   Reply With Quote
Old 07-18-2008, 03:15 PM   #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?
Oxidoreductase is offline   Reply With Quote
Old 07-18-2008, 03:20 PM   #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.
Kasturi is offline   Reply With Quote
Old 07-18-2008, 03:49 PM   #18
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Quote:
Originally Posted by Kasturi View Post
there are 40320 different combinations of 12345678


Out of those there are 3112 that are divisible by 13.
Ahh, I was counting values where 1-8 could appear more than once. This answer is correct.
faulkner132 is offline   Reply With Quote
Old 07-18-2008, 03:57 PM   #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.
Oxidoreductase is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -5. The time now is 03:24 AM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0