Help with an example of checking friends numbers in PHP, I can not find any example or tutorial on the web
Two positive integers A and B are friendly numbers if the sum of the proper divisors of A is equal to B and the sum of the proper divisors of B is equal to A.
The divisors of a number include the unit but not the number itself.
I AM NEW IN PHP AND I TRY TO MODIFY A CODE THAT FINDS JAVA:
if($_POST)
{
$num1 = $_POST
['numero1'];
$num2 = $_POST
['numero2'];
$suma = 0;
for($i=1;$i<$num1;$i++){
if($num1%$i==0){
$suma=$suma+$i;
}
}
if($suma==$num2){
$suma=0;
for($i=1;$i<$num2;$i++){
if($num2%$i==0){
$suma=$suma+$i;
}
}
if($suma==$num1){
echo 'Son Amigos';
}else{
echo 'No son Amigos';
}
}
else{
echo 'No son Amigos';
}
}
}