0

Who can make sum of two hundred integers ?

1895 contans 4 integers but i want 200

1st Nov 2017, 4:46 PM
mahdi
mahdi - avatar
5 Respuestas
0
<?php $start=0; while ($start < 200) { $random=rand(1,9); $array[]=$random; $start++; } echo "<pre>"; print_r($array); echo "</pre>"; ?>
1st Nov 2017, 9:06 PM
iizegrim
iizegrim - avatar
0
hey i meant sum of two hundred digits 1895+2343=xxxx is sum of two 4 digits and i want two hundred digit sum
2nd Nov 2017, 1:38 AM
mahdi
mahdi - avatar
0
hmmm ... u mean 100digits + 100digits=sum? ... and if so ... whats the problem?
2nd Nov 2017, 4:31 AM
iizegrim
iizegrim - avatar
0
yeah i want u to write its algorithm
2nd Nov 2017, 4:41 AM
mahdi
mahdi - avatar
0
<?php $start=0; while($start<=99) { $array_1[]=rand(1,9); $array_2[]=rand(1,9); $start++; } $digit=array(implode($array_1),implode($array_2)); echo "digit 1: " . $digit[0] . "<br/>"; echo "digit 2: " . $digit[1] . "<br/>"; echo "sum: " . number_format(array_sum($digit)); ?>
2nd Nov 2017, 5:33 AM
iizegrim
iizegrim - avatar