Problem # 20 : Key numbers
Any sequence of strictly positive integers can be expressed as a single key number using the following technique :-
Example : 4
5
2
1 can be expressed as 24 x 35
x 52 x 71 = 680400
i.e
the n-numbers are the exponents of the first n-prime numbers.
Write a sub-routine KEYNO(A) which applies prime factorization to the key number A to give the sequence.
You can assume that the number is a product of successive primes.
(i.e
it cannot be 22 x 71,
it must be successive
primes)
Sample Output
KEYNO(60) will return 2
1
1 (as 60 = 22 x 31 x 51)
KEYNO(72) will return 3
2 (as 72 = 23 x 32)
![]() |