Armstrong

in ita •  2 months ago 

declare(strict_types=1);

function isArmstrongNumber(int $number): bool
{
$res = 0;
$str_cr = (string)$number;
$len = strlen((string)$number);
for($i=0; $i<$len; $i++)
{
$res += ((int)$str_cr[$i]) ** $len;
var_dump($res);
}
return $number == $res;

}

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!