aspose file tools*
The moose likes Programming Diversions and the fly likes Use five 5s to make 37 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Use five 5s to make 37" Watch "Use five 5s to make 37" New topic
Author

Use five 5s to make 37

Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Fill in the operators for the following equation. You may use any operators you wish. There should be at least two different ways to solve this equation.
5 5 5 5 5 = 37
[Note: The solution to the equation is 37. As such, you may not split up the '3' and the '7' by placing any operators in between them.]
[ July 20, 2003: Message edited by: Jason Menard ]
Roy Tock
Ranch Hand

Joined: Jul 16, 2001
Posts: 83
Let I be the set of integers. Define an operation op on IxIxIxIxI such that op(5, 5, 5, 5, 5) = 37. Then
op(5, 5, 5, 5, 5) = 37. QED :-)

Here's another that's more likely to be among Jason's solutions, assuming base ten arithmetic:
((55)/5)+5+5=(3*7)
Another is
5+5+((55)/5)=(3*7)
A third is
5+((55)/5)+5=(3*7)
Those three are all basically the same, though. Maybe there's another? Neat...I wasn't thinking about 3*7 at first.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8764
    
    5
Didn't think we could split up the 37, but if so how about...
(55/5) - (5/5) = 3 + 7
or
(5/5) - ((5*5)/5) = 3 - 7


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
No splitting up the 37.
Kao-Wei Wan
Greenhorn

Joined: Jun 02, 2003
Posts: 7
Originally posted by Jason Menard:
No splitting up the 37.

55555 != 37
5-5-5-5-5 != 37
just kidding
Jignesh Malavia
Author
Ranch Hand

Joined: May 18, 2001
Posts: 81
hints
a) 2^5=32 (if power is allowed)
b) 1<<5=32 and 5|5=5
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Originally posted by Jignesh Malavia:
hints
a) 2^5=32 (if power is allowed)
b) 1<<5=32 and 5|5=5

2^5 won't work because there is no 2, and '^' is used in programming languages as an exponent operator, but isn't a real math operator. Even if it were to be used, then you could get something like 5^5. but not 2^5. Bit shifting, while being a Java operator, is also not a math operator in the true sense of the word (human beings have no need to bit encode digits to manipulate them, that's a computer thing). You're best bet would be to stick with the normal mathematical operators imho.
[ July 20, 2003: Message edited by: Jason Menard ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Is factorial allowed?
(5 x 5) + 5! - (5!/5)
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Which of the following is allowed:
1) Factorial
Most problems of this nature do accept ! as a valid mathematical symbol.
2) Summation
Some accept this, some do not. Those who do not argue that you need two numbers to define a summation. Those who do, allow a single number, with the terminal base to be implied as zero.
3) (Square) Roots
Are square roots allowed? Are other roots? A root sign typically has a a number associated with it. Some allow for a root sign sans number to imply a square root.
4) Rounding, Flooring, trig functions, etc
Can we allow other functions which are typically represented by alphabetic symbols?
--Mark
boyet silverio
Ranch Hand

Joined: Aug 28, 2002
Posts: 173
is this allowed?
++5 * 5 + ++5 + 5/5 = 37
Jignesh Malavia
Author
Ranch Hand

Joined: May 18, 2001
Posts: 81
Originally posted by Jason Menard:

2^5 won't work because there is no 2
Yes, but we can get one using (5+5)/5
Even if it were to be used, then you could get something like 5^5. but not 2^5.
(((5+5)/5)^5)+5 = 37
Bit shifting, while being a Java operator, is also not a math operator in the true sense of the word (human beings have no need to bit encode digits to manipulate them, that's a computer thing).
Well, okay. If it were allowed, my answer was ((5/5)<<5)|5|5
You're best bet would be to stick with the normal mathematical operators imho.
So is factorial (!) allowed? In that case Michael Dunn was pretty close.
(5 x 5) + 5! - (5!/5)
(5 * 5) + (5! / (5+5))
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
I'm sure this works better in a non-programmer crowd.
The solutions I have seen maybe (or maybe not) use the following math operators: (,),+,-,*,/,!. (<-- that's a period, not a decimal point) It is also acceptable to run numbers together, so that in this case you could use numbers such as 5, 55, 555, etc...
In other words, pretty much the basic stuff. No functions (floor, ceiling, rounding, trig functions, etc...). No increment or decrement (pre or post). I suppose square root would probably be allowed, but I'm guessing not other roots as that would call for an additional number. In any case the solution does not call for it. Nor does the solution call for raising anything to the 5th or 55th or 555th power (not sure if that is even acceptable in these types of problems though). As far as summations, I would think that you would need another number, right? The place I grabbed this from didn't go into much detail so all I can tell you is the symbols I have seen similar problems use (and of course I've seen the solution for this one.
[ July 20, 2003: Message edited by: Jason Menard ]
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Originally posted by Jignesh Malavia:
(5 * 5) + (5! / (5+5))

Good job! That is a correct answer. I know of at least two more.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
A factorial is a "normal" operator but exponentiation is not? You've got some weird definitions here, Jason.


"I'm not back." - Bill Harding, Twister
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Originally posted by Jim Yingst:
A factorial is a "normal" operator but exponentiation is not? You've got some weird definitions here, Jason.

I don't think that I said that exponentiation wasn't acceptable, merely that I didn't know. However since you all are making me put way more work into this then I had planned , further researching my sources indicates that exponentiation is indeed acceptable. I have seen it indicated as either ** or ^. Square roots are also acceptable.
My appologies for the confusion. Sheesh... computer people.
[ July 20, 2003: Message edited by: Jason Menard ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
(5 x 5) + 5! - (5!/5)
oops... I was thinking 5! was 1+2+3+4+5
Is there a sumof operator?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
I don't think that I said that exponentiation wasn't acceptable, merely that I didn't know.
True, but you tried to discourage it.
'^' is used in programming languages as an exponent operator, but isn't a real math operator
Of course ^ is just computer shorthand for the "real" (i.e. more common) mathematical notation, which would be to write the exponent as a superscript. Doesn't even require any extra symbols; it's purely positional. Just as valid as the "operator" that says two fives next to each other == fifty-five. Except we can't show it properly in this forum without the ^ symbol because HTML is off.
George Harris
Ranch Hand

Joined: May 05, 2003
Posts: 84
I think this is another solution
(5! + 5! - 55)/5
James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
Looks correct!


Author and Instructor, my book
tim hudson
Greenhorn

Joined: Aug 20, 2003
Posts: 1
This one works too
(5! / (5 + 5)) + (5 * 5)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use five 5s to make 37
 
Similar Threads
operator precedence
Unary, Increament Operators
Nine 4s to make 2000
the world's smallest number?
JTABLE