Well... you can make an algorithm to store all prime factors of the two numbers, remove all the common numbers, and then multiply each array back together to get your ratio.
But seriously... if you are doing this for screen sizes, use something like this:
`%Project Title%
`%Source File Name%
`======================
Dim ScreenParams(2)
DisplayMode$=SelectScreenMode(): Rem <<< This calls the function. On return the new mode is already set
Center Text Screen Width()/2,Screen Height()/2, "Now In Screen Mode "+DisplayMode$: Rem <<< Selected screen mode returned in string (Eg 800x600x32)
Wait Key
End
Function SelectScreenMode()
Set Text Font "Arial": Set Text Size 14
Perform Checklist For Display Modes
ListNum = Checklist Quantity()
TRows = ListNum/4+1: TColumns = 4: THeight = Text Height("X")
BoxHeight = THeight*TRows+40: BoxWidth = TColumns*90
X=(Screen Width() - BoxWidth)/2: Y=(Screen Height() - BoxHeight)/2
Ink RGB(255,255,255),0: Box X,Y,X+BoxWidth,Y+BoxHeight
Ink RGB(180,180,180),0: Box X+1,Y+1,X+BoxWidth,Y+BoxHeight
Ink RGB(220,220,220),0: Box X+1,Y+1,X+BoxWidth-1,Y+BoxHeight-1
Ink RGB(255,255,255),0: Center Text Screen Width() / 2,Y+5,"Please Select The Required Screen Mode:"
Ink 0,0: Center Text Screen Width() / 2-1,Y+4,"Please Select The Required Screen Mode:"
TextLPos = X+10: TextTPos = Y+30: RowCount=0: Ink 0,0
For N=1 To ListNum
Text TextLPos,TextTPos,CHECKLIST STRING$(N)
Inc TextTPos,THeight: Inc RowCount
If RowCount = TRows
RowCount=0: TextTPos = Y+30
Inc TextLPos,90
Endif
Next N
Get Image 10000,X,Y,X+BoxWidth,Y+BoxHeight,1
Ink RGB(120,120,220),0: Set Text Transparent
Repeat
Mx=MouseX(): My=MouseY(): Mc=MouseClick()
If Mx>(X+10) and Mx<(X+BoxWidth-10) and My>(Y+30) and My<(Y+BoxHeight-10)
OverColumn = (Mx-(X+10))/90: OverRow = (My-(Y+30))/THeight
ItemNum = OverColumn* TRows +OverRow+1
If OldItemNum <> ItemNum And ItemNum >= 0 And ItemNum <= ListNum
Paste Image 10000,X,Y
Text OverColumn*90+X+10,OverRow*THeight+30+Y,CHECKLIST STRING$(ItemNum)
OldItemNum = ItemNum
Endif
Endif
Until Mc=1 And ItemNum <= ListNum
Mode$ = CHECKLIST STRING$(ItemNum)
Delete Image 10000
BitDepth = VAL(Right$(Mode$,2))
NewMode$=Left$(Mode$,Len(Mode$)-3)
For N=1 To Len(Mode$)
If Mid$(NewMode$,N)="x"
XRez = VAL(Left$(NewMode$,N-1))
YRez = VAL(Right$(NewMode$,Len(NewMode$)-N))
Exit
Endif
Next N
ScreenParams(0)=XRez
ScreenParams(1)=YRez
ScreenParams(2)=BitDepth
Set Display Mode XRez, YRez, BitDepth
Ink RGB(255,255,255),0
EndFunction Mode$
