can be obtained as a product of some positive integers (greater than 1) in 7 different ways as following; Similarly, can also be obtained in 7 different ways as following;
In how many ways can we can get nine nines by multiplying two or more numbers such that order of the factors matters?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The problem asks for 9 9 9 9 9 9 9 9 9 but let's solve for a general n . Suppose S is the set of all numbers that divide n different from 1 and itself, we could choose any of them to be the first number we write and there are ∣ S ∣ numbers we can choose. Now, let's say that f ( n ) is the number of ways you can write n and s i is a member of our set, for each s i we choose to be the first one we use, there are f ( s i n ) + 1 ways of writing the number being that you could write s i ⋅ s i n or s i times any of the ways of witting s i n . This gets us to the formula:
f ( n ) = ∣ S ∣ + s i ∈ S ∑ f ( s i n )
Now that we got the recursive relation is time to get the base case, and for this is quite simple, there are 0 ways of writing any prime number as a multiple os 2 numbers different than 1 and itself so if n is prime f ( n ) = 0 . Since we are only dividing n on our algorithm, we eventually get to a prime input n . Here is my python implementation of the algorithm.