Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!

# Use five 5s to make 37

Jason Menard
Sheriff
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
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
Posts: 8898
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

Jason Menard
Sheriff
Posts: 6450
No splitting up the 37.

Kao-Wei Wan
Greenhorn
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
Posts: 81
hints
a) 2^5=32 (if power is allowed)
b) 1<<5=32 and 5|5=5

Jason Menard
Sheriff
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
Posts: 4632
Is factorial allowed?
(5 x 5) + 5! - (5!/5)

Mark Herschberg
Sheriff
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
Posts: 173
is this allowed?
++5 * 5 + ++5 + 5/5 = 37

Jignesh Malavia
Author
Ranch Hand
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
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
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
Posts: 18671
A factorial is a "normal" operator but exponentiation is not? You've got some weird definitions here, Jason.

Jason Menard
Sheriff
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
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
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
Posts: 84
I think this is another solution
(5! + 5! - 55)/5

James Chegwidden
Author
Ranch Hand
Posts: 201
Looks correct!

tim hudson
Greenhorn
Posts: 1
This one works too
(5! / (5 + 5)) + (5 * 5)