There is so much I don't know where to get started...
for example:
	PHP Code:
	
while(uk+1<=ans) {
      uk++;
      solve = uk;
      sleep(0.05);
      if (ans/uk=thing) { //replace the / with the mathematical symbol you require.
         echo("The answer is" SPC uk);
      }
    } 
 
What's the point of having sleep() and what is solve = * used for?
Plus, in the java code, why did you use float? You're adding an integer on each, this is not the solution, preferably it's better if you use a mathematical equation and not loop through numbers... What if an answer was decimal? Code won't help you here.