In the expression
2x * 3y * 5z
The x
, y
and z
can take non negative integer value (>=0).
So the function would generate a series of number 1,2,3,4,5,6,8,9,10,12,15,16....
- I have a brute force solution.
- I would basically iterate in a loop starting with 1 and in each iteration I would find if the current number factors are only from the set of 2,3 or 5.
What I would like to have is an elegant algorithm.
This is an interview question.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…