HP Forums

Full Version: 12c program how many factors does a number have
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Haven't you ever wondered how many factors a certain number has? If you have, would you like a quick way to find out on the HP-12c?

Code:

Reg 0 = input #
Reg 1 = factor count
Reg 2 = square root of input #
Reg 3 = trial factor

Enter the number you are curious about and press R/S.  On the newer 12c+, it will give you the answer very quickly; on the older ones, a bit longer.

The RPN program is only 28 lines long (a perfect number, by the way).

01 STO 0
02 SQRT X
03 STO 2
04 FRAC
05 X=0
06 GOTO 09
07 2
08 GOTO 10
09 1
10 STO 1
11 2
12 STO 3
13 RCL 0
14 X<-->Y
15 /
16 FRAC
17 X=0
18 GOTO 20
19 GOTO 22
20 2
21 STO+1
22 1
23 STO+3
24 RCL 2
25 RCL 3
26 X<=Y
27 GOTO 13
28 RCL 1

I once learned a quick way to determine the number of factors a number has using pencil and paper. Do the prime factorization of the number. Then, add 1 to the exponent of each prime factor and multiply these numbers together. The answer is the number of factors that the number has.
Reference URL's