wood burning stoves*
The moose likes Programming Diversions and the fly likes Math: abc = 1536 and... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Math: abc = 1536 and..." Watch "Math: abc = 1536 and..." New topic
Author

Math: abc = 1536 and...

J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 84
Hello guys...!

It's very funny because my little brother asked me this question;



What are the possibilities of a, b, and c ?

Could any body help me,
1st) What topic in math is this that I should look upon?
2nd) Step by step how to solve it (the way)...?
3rd)... your kindness....


Somebody outthere give me short explaination meanwhile, I need to erase my stupidity because of not aware of this calculation in my head. Anyway here is the words



But here, my concern is... why 2^9 could be 2^4 + 2^3 + 2^2 instead of 2^4 x 2^3 x 2^2
for that solving case?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

If it is really a math question and not a trick question, then there is not enough information to solve for a, b and c.

For three unknowns, you need three distinct equations to solve the problem.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4244
    
    7

Bear Bibeault wrote:If it is really a math question and not a trick question, then there is not enough information to solve for a, b and c.

For three unknowns, you need three distinct equations to solve the problem.

I suspect the question is asking for (positive?) integer solutions. Which will at least give you a finite number of possibilites.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

Solving uniquely for three variables takes three linear equations, but abc = 1536 is not linear. I remember one branch of math where you could optimize one formula based on an insufficient number of linear equations. I believe it was called linear programing, though it had nothing to do with computers.

In any case, that's not what you're doing here. You're looking for a fast way to find the integer solution to these equations. Factoring 1536 into 3 * 2^9 is a good way to start because it gives you all the factors that will make up a, b, and c. It's a bit hard to explain if that doesn't click for you. 2^9 of course doesn't equal 2^4 + 2^3 + 2^2, but you will build up a, b, and c by multiplying one 3 with nine 2s. That gives you a quick way to limit your search for a solution.

When I just did it on paper, I started with a = 6 (3x2), and b = 16 (2x2x2x2), which left four of our nines 2s so c was forced to be 16. (I'm finding it difficult to explain what I mean by "left four of nine 2s". I think you'll either get it, or you won't.) Anyway, that meant the sum of a,b, and c was 38, almost right but not quite. So I thought to bring one of those 2s over to a, making it 12, and taking it away from b, making it 8. That kept c at 16. So, I got the answer in two guesses.

The technique of making a guess, and comparing its results to the true solution, and then adjusting, is called regula falsi. I don't know a name for the rest of what I did. Maybe we can call it JFM?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10925
    
  12

Why is abc = 1536 non-linear? I assume it means a * b * c = 1536.
A linear equation is an algebraic equation in which each term is either a constant or the product of a constant and (the first power of) a single variable.


each variable is a first power, and the constant is 1 in each case...

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4244
    
    7

Combinatorics? The brute force approach involves generating all possible combinations of three factors, and then checking the second condition.

Here's one pattern you could follow:
Of course, you can instantly rule out any combinations with 2^6 and above, or 3x2^4 and above, as they instantly exceed the target.

(All assuming we're talking positive integers, of course)
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4244
    
    7

fred rosenberger wrote:Why is abc = 1536 non-linear? I assume it means a * b * c = 1536.

Because you're multiplying variables together. It doesn't satisfy the "single variable" part of that definition.
Sai Hegde
security forum advocate
Ranch Hand

Joined: Oct 26, 2010
Posts: 198

Factorize and permutate...
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

Taking the brute force approach and to have some fun with Haskell:



which returned [(8,12,16),(8,16,12),(12,16,8)]


- Marimuthu Madasamy
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2970
    
    9
Very nice.

If we allow negative numbers (and why not?), there's another set of solutions: (-8,-4,48) and its permutations.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10925
    
  12

Matthew Brown wrote:
fred rosenberger wrote:Why is abc = 1536 non-linear? I assume it means a * b * c = 1536.

Because you're multiplying variables together. It doesn't satisfy the "single variable" part of that definition.

duh...sorry.
J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 84
Marimuthu Madasamy wrote:Taking the brute force approach and to have some fun with Haskell:



which returned [(8,12,16),(8,16,12),(12,16,8)]


waaah, I never calculate in this manner.... guys, are you all taking math class right now?
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2970
    
    9
Not really. It's a program in the Haskell programming language. Personally I was learning about it as part of reading Seven Languages in Seven Weeks, which we had as a reading group at work. (By the way, if you do this: I recommend taking more than seven weeks. Maybe fourteen weeks. You can learn a lot if you work through all the problems, but it can take a lot of time.) I don't know if I will ever program in Haskell professionally, but it's a really good way to stretch your brain.
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

Though Mathematical skills would help in programming, the above code is straightforward, taking the brute force approach. Further I also have been learning Haskell for one month and really love the language. Learning Haskell would definitely improve your programming skills and your way of thinking in programming.
J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 84
Mike Simmons wrote:Not really. It's a program in the Haskell programming language. Personally I was learning about it as part of reading Seven Languages in Seven Weeks, which we had as a reading group at work. (By the way, if you do this: I recommend taking more than seven weeks. Maybe fourteen weeks. You can learn a lot if you work through all the problems, but it can take a lot of time.) I don't know if I will ever program in Haskell professionally, but it's a really good way to stretch your brain.


waw.... i've never involved in what that haskell thing....
great Mike, keep it up! is it difficult than our programming language or ....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Math: abc = 1536 and...
 
Similar Threads
Regex - Difference in ^[abc] and [^abc]
Break back to Topic Menu
Jscript - java and authorizenet
how to compare the values in arrays
simple proof make your mind mad