HP Forums
silly math puzzle - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: silly math puzzle (/thread-13831.html)



silly math puzzle - Wes Loewer - 10-21-2019 08:51 AM

Today is a national holiday which means that I have too much time on my hands, which led to this silly little math puzzle.

You have probably seen the 8/2(2+2) thing that was going around the internet a couple of months ago. The big argument was whether the answer was 1 or 16. Casios give 1, TI's gives 16. How about the Prime? Since PPL doesn't allow implied multiplication, I had to put in explicit multiplication. Look at the RETURN line and predict what you think the output will be.

Code:
#pragma mode( separator(/+;) integer(h64) )

EXPORT PUZZLE()
BEGIN
 RETURN 8/2*(2+2);
END;

Now run the program and see if you were right. ;-)

Happy Mashujaa Day!


RE: silly math puzzle - John Keith - 10-21-2019 11:34 AM

For the record, the HP 50 returns 16.


RE: silly math puzzle - toml_12953 - 10-21-2019 01:09 PM

(10-21-2019 08:51 AM)Wes Loewer Wrote:  Today is a national holiday which means that I have too much time on my hands, which led to this silly little math puzzle.

You have probably seen the 8/2(2+2) thing that was going around the internet a couple of months ago. The big argument was whether the answer was 1 or 16. Casios give 1, TI's gives 16. How about the Prime? Since PPL doesn't allow implied multiplication, I had to put in explicit multiplication. Look at the RETURN line and predict what you think the output will be.

Code:
#pragma mode( separator(/+;) integer(h64) )

EXPORT PUZZLE()
BEGIN
 RETURN 8/2*(2+2);
END;

Now run the program and see if you were right. ;-)

Happy Mashujaa Day!

Using PMDAS, the answer is 16 which is what you'd get if doing it by hand or with an algebraic machine. With RPN, you have to know the rules to do it properly.

8/2*(2+2)
Parentheses first
8/2*4
Division next since multiplication and division are done in order from left to right
4*4
Multiplication next
16


RE: silly math puzzle - StephenG1CMZ - 10-21-2019 01:53 PM

The Prime is interesting.
In PPL the implied multiply is required: 16 is returned (but not from an exact copy of the specified program).
In Home (Textbook) the implied multiply is optional: 1 is returned in both cases (with no use of cursor the parentheses default to the divisor).
In Home (algebraic) : 16 is returned in both cases.
In CAS the implied multiply is required: 1 returned.

Updated to include results for Home(Textbook) and Home(algebraic), as it makes a difference.


RE: silly math puzzle - toml_12953 - 10-21-2019 02:38 PM

(10-21-2019 01:53 PM)StephenG1CMZ Wrote:  The Prime is interesting.
In Home the implied multiply is optional: 1 is returned in both cases.

Both cases? In Home I get 16 whether implied or expressed multiplication is used. The Prime fills in the missing * when copying and pasting the expression to the command line also.

I have Entry set to Algebraic.


RE: silly math puzzle - Wes Loewer - 10-21-2019 02:41 PM

So far, you're all missing the point. I think if you actually save the program and run it, you will be humorously surprised at the result. Hint: It's neither 1 nor 16. It's not very pragmatic, but it is kind of fun.
(Make sure you copy the entire program.)


RE: silly math puzzle - StephenG1CMZ - 10-21-2019 03:02 PM

(10-21-2019 02:38 PM)toml_12953 Wrote:  
(10-21-2019 01:53 PM)StephenG1CMZ Wrote:  The Prime is interesting.
In Home the implied multiply is optional: 1 is returned in both cases.

Both cases? In Home I get 16 whether implied or expressed multiplication is used. The Prime fills in the missing * when copying and pasting the expression to the command line also.

I have Entry set to Algebraic.
I had Home set to Textbook.


RE: silly math puzzle - grsbanks - 10-21-2019 03:07 PM

I wonder how many here ignored the #pragma statement?

It says that the decimal point is '/' and the "comma" (used to separate items in a list or the real and imaginary parts of a complex number) is '+'.

If you then replace those symbols with what we're used to seeing in the RETURN statement, you get:

Code:
RETURN 8.2*(2,2);

That should explain why you get 16.4+16.4*i


RE: silly math puzzle - toml_12953 - 10-21-2019 03:08 PM

(10-21-2019 02:41 PM)Wes Loewer Wrote:  So far, you're all missing the point. I think if you actually save the program and run it, you will be humorously surprised at the result. Hint: It's neither 1 nor 16. It's not very pragmatic, but it is kind of fun.
(Make sure you copy the entire program.)

OIC! Hahahaha! Since / and + are now separators, we do get a funny answer!


RE: silly math puzzle - Wes Loewer - 10-21-2019 03:21 PM

(10-21-2019 03:07 PM)grsbanks Wrote:  I wonder how many here ignored the #pragma statement?

too subtle?

Quote:you're all missing the point...
It's not very pragmatic ...

I've been sitting on that one for years. I kept meaning to post it on April Fools Day, but I kept forgetting.


RE: silly math puzzle - toml_12953 - 10-21-2019 05:51 PM

(10-21-2019 03:21 PM)Wes Loewer Wrote:  
(10-21-2019 03:07 PM)grsbanks Wrote:  I wonder how many here ignored the #pragma statement?

too subtle?

Quote:you're all missing the point...
It's not very pragmatic ...

I've been sitting on that one for years. I kept meaning to post it on April Fools Day, but I kept forgetting.
Quite a good AF joke, too! I must need more coffee to have missed it.


RE: silly math puzzle - cyrille de brébisson - 10-22-2019 04:53 AM

Nice one!