Post Reply 
Triangular number AND sum of first m factorials
01-10-2018, 04:58 AM
Post: #8
RE: Triangular number AND sum of first m factorials
(01-10-2018 04:03 AM)Gerson W. Barbosa Wrote:  ISPF? (IsPerfectSquare?) has yet to be implemented. It should return 1 when the argument is a perfect square and 0 otherwise.

The HP 50g LongFloat library contains a function like the one you're looking for. It's called ZSqrt, and it returns IP(sqrt(x)) to level 2, and a 0 or 1 to level 1, with 1 meaning that x was a perfect square. It works on integers of any length.

Gerald H also posted a program HERE which seems to do essentially the same thing. It returns IP(sqrt(x)) to level 2 of the stack, and on level 1 it leaves a SysRPL TRUE if x was a perfect square, otherwise a FALSE. That's the same idea as HP's FPTR2 ^ZSQRT, but Gerald's program is more accurate; see Gerald's posting for evidence of HP's function's inaccuracy.

BTW, LongFloat's ZSqrt function gets the same result as Gerald's program when given the example in Gerald's posting, so I surmise that ZSqrt is trustworthy.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Triangular number AND sum of first m factorials - Joe Horn - 01-10-2018 04:58 AM



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