I am trying to write a program that takes a number with a single leading integer and an arbitrary number of trailing zeros and then prints all possible combinations of two factors.
ie.
100
factors are 2^2, 5^2
so the program would print:
(2,50),(4,25),(5,20)
or
600
factors are 2^3,3,5^2
(2,300),(4,150),(8,75),(3,200),(5,120),(25,24),(6,100),(12,50),(15,40),(30,20),(60,10)
…I think that’s all of them? Is it? I could use a program to check…
import itertools
facts=[[2,2,2],[3],[5,5]]
for n in itertools.product(*facts)
print(n)
I see that I am using this incorrectly but that was my first stab at it.
This just gives (2,3,5) ten times.
I want something like (2) * (2,3,5,5) and (2,2) * (3,5.5) and the like…
To generate all factors of a number given its prime factors:
Example
To produce pairs:
Output
It works for small numbers. You could use it to test your solution that could take into account the special form of your numbers:
x00000...