There's probably a better algorithm for this, but off the top of my head:
1) Take the square root of the number X; we'll call it N.
2) Set N equal to the ceiling of N (round up to the nearest integer).
3) Test for (X % N). If N divides evenly into X, we found our first number.
if 0, divide X by N to get M. M and N are our numbers
if not 0, increment N by 1 and start step 3 over.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…