Write a program which can print the following sequences: Sample Output: 1, 10, 100, 1000, ……, N 1, 3, 6, 10, 15, ……, N

Problem number : 1 

Write a program which can print the following sequences:

Sample Output:

1, 10, 100, 1000, ……, N

1, 3, 6, 10, 15, ……, N


Solution for this problem :


<?php
//echo "Hello World !";
echo "<br/>";
$a=1;
 
for($i=0;$i<4;$i++){
echo $a;
echo ",&nbsp;";
$a=$a*10;
}
echo "...... , N";
echo "<br/>";
echo "<br/>";
$n=1;
for($j= 0; $j < 5; $j++){
$res = $n*($n+1)/2;
echo $res;
$n++;
echo ",&nbsp;";
}
echo "...... , N";
echo "<br/>";
echo "<br/>";
?>

Sample Output:

1, 10, 100, 1000, ……, N

1, 3, 6, 10, 15, ……, N






মন্তব্যসমূহ

Popular Posts

Simple 2D hut design in computer graphics using c++

HashMap in Java