[PHP] print even numbers (intermediate coding challenge)
Why this challenge not pass when submitted?
QUestion:
Write a program to print the even numbers between 0 to n
Write a program to print the even numbers between 0 and n ( read from input ) in comma separated form.
Example input:
10
Example output:
0,2,4,6,8,10
my code:
<?php
$num = readline();
$res = '0';
for($i=1; $i <=$num; $i++){
if($i % 2 == 0 ){
$res .= ','.$i;
}
}
echo $res;
?>
thanks
1 Answer
4 years ago by Marco Ginato
@Marco Ginato
There was an issue with the problem, we have fixed it. Can you please re-try submitting it?
4 years ago by OneCompiler