php - Find a 4-digit number which, when multiplied by 4 yields the same number in reverse? -



php - Find a 4-digit number which, when multiplied by 4 yields the same number in reverse? -

i trying write simple programme in php cannot understand going wrong - here i've tried far:

function multipliedbyreverseorder() { ($i = 1000; $i <=9999; $i++) { $value_a = $i; $value_b = $i*4; $new_value_a=$value_a; $new_value_b=$value_b; if($new_value_a==$value_a||$new_value_b==$value_b){ } } $exact_value_a=$value_a*$new_value_a; $exact_value_a=$new_value_b; if ($exact_value_a == $exact_value_b) { echo $exact_value_a . "the result is:"; } }

you can reverse string using strrev function.

function multipliedbyreverseorder() { ($i = 1000; $i <=9999; $i++) { $a = $i; $b = $i*4; $c = strrev($b); if($a == $c) { echo "result is:". $a; } } }

php

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -