Post Reply 
silly math puzzle
10-21-2019, 08:51 AM
Post: #1
silly math puzzle
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!
Find all posts by this user
Quote this message in a reply
10-21-2019, 11:34 AM
Post: #2
RE: silly math puzzle
For the record, the HP 50 returns 16.
Find all posts by this user
Quote this message in a reply
10-21-2019, 01:09 PM
Post: #3
RE: silly math puzzle
(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

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-21-2019, 01:53 PM (This post was last modified: 10-21-2019 02:58 PM by StephenG1CMZ.)
Post: #4
RE: silly math puzzle
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.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
10-21-2019, 02:38 PM
Post: #5
RE: silly math puzzle
(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.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-21-2019, 02:41 PM (This post was last modified: 10-21-2019 02:43 PM by Wes Loewer.)
Post: #6
RE: silly math puzzle
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.)
Find all posts by this user
Quote this message in a reply
10-21-2019, 03:02 PM
Post: #7
RE: silly math puzzle
(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.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
10-21-2019, 03:07 PM (This post was last modified: 10-21-2019 03:13 PM by grsbanks.)
Post: #8
RE: silly math puzzle
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

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
10-21-2019, 03:08 PM
Post: #9
RE: silly math puzzle
(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!

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-21-2019, 03:21 PM
Post: #10
RE: silly math puzzle
(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.
Find all posts by this user
Quote this message in a reply
10-21-2019, 05:51 PM
Post: #11
RE: silly math puzzle
(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.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-22-2019, 04:53 AM
Post: #12
RE: silly math puzzle
Nice one!

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 4 Guest(s)