text: Reach A and B by multiplying them with K and K ^ 2 at every step | function to check is it is possible to reach A and B starting from 1 and 1 ; find the cuberoot of the number ; divide the number by cuberoot ; if it is a perfect cuberoot and divides a and b ; Driver Code
code: < ? php function possibleToReach ( $ a , $ b ) { $ c = ( $ a * $ b ) ; $ re1 = $ a / $ c ; $ re2 = $ b / $ c ; if ( ( $ re1 * $ re1 * $ re2 == $ a ) && ( $ re2 * $ re2 * $ re1 == $ b ) ) return 1 ; else return -1 ; } $ A = 60 ; $ B = 450 ; if ( possibleToReach ( $ A , $ B ) ) echo " yes " ; else echo " no " ; ? >