4
05/11/2024 3:11 अपराह्न
विषय प्रारंभकर्ता
Write a program, which receives a number – n, and prints a triangle from 1 to n as in the examples.
Examples:

2 उत्तर
3
05/11/2024 3:12 अपराह्न
This is my solution:
<?php
$number = readline();
for ($i = 1; $i <= $number; $i++) {
for ($n = 1; $n <= $i; $n++) {
echo $i . " ";
}
echo PHP_EOL;
}
2
05/11/2024 3:13 अपराह्न
Mine:
<?php
$end = intval(readline());
for ($row = 1; $row <= $end; $row++) {
for ($col = 0; $col <= $row; $col++) {
echo "$row ";
}
echo PHP_EOL;
}
