PHP Compiler
<!DOCTYPE html> <html> <body> <?php $num = 1000001; $arr = []; $i = -1; $total = 0; while($num != 0) { $i++; $arr[$i] = $num % 10; $num = $num / 10; $num = floor($num); } for($j=$i; $j>=0; $j--) $total += ($arr[$j] * pow(2, $j)); echo "Decimal number of $num (binary) is $total"; ?> </body> </html>
OUTPUT
Decimal number of 1000001 (binary) is 65
×

Save as Private