You have to decompose a positive integer/fraction as a product of powers of factorials of prime numbers.
For example
22 = (11!)^1 × (7!)^(−1) × (5!)^(−1) × (3!)^(−1) × (2!)^1
10/9 = (5!)^1 × (3!)^(−3) × (2!)^1
Use this special notation: prime number#power
to denote each term, e.g. (11!)^4
is denoted as 11#4
.
Output the non-zero terms only, with space separation.
The above examples hence become:
22 = 11#1 7#-1 5#-1 3#-1 2#1
10/9 = 5#1 3#-3 2#1
Input & Output
- You are given a positive number
N
, that can be either an integer or a fraction of the formnumerator/denominator
- The ordered list of the non-zero terms of the decomposition of
N
, denoted using the special notation - You are allowed to output the terms as a list/array (containing strings with the special notation
#
) - You are allowed to output the terms in any order
- Duplicate prime numbers are allowed
- You are not allowed to use terms that have to the power of
0
Test cases
6 -> 3#1
5040 -> 7#1
22 -> 11#1 7#-1 5#-1 3#-1 2#1
1/24 -> 3#-1 2#-2
720/121 -> 11#-2 7#2 5#3 3#3
This is code-golf, shortest code wins!
Credits to this puzzle
#
notation is mandatory, but the join by spaces is optional. \$\endgroup\$7 -> 7#1, 5#-1, 3#-1, 2#0
? \$\endgroup\$