HP Forums

Full Version: Perfect NumBer.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I submit a new little routine wich give if a number is perfect, ie equal to it's propers divisors :

6=1+2+3, 1+2+3=6 it is perfect number.
8=1+2+4, 1+2+4=7 it is not.
28=1+2+4+7+14 it is.

And so on.
Code:

01 LBL'PNB'
02 LBL A
03 LocR 001
04 # 000
05 INC X
06 [cmplx]ENTER
07 RCL+ X
08 x[<->] T
09 x<? T
10 SKIP 007
11 RCL Z
12 RMDR
13 RCL+ Z
14 x=? Z
15 STO+ .00
16 x[<->] Z
17 BACK 012
18 RCL .00
19 x[!=]? Y
20 CLSTK
21 RTN
22 END

Specials thanks to Didier and Dieter for good programming !


Good week-end.
If you see the number entered then it is a perfect number.
If you see zero it is not.
Reference URL's