PHP program to print Triangle number in reverse pattern
1. Program to print Triangle number in reverse pattern
<?php for($i=6;$i>=1;$i--) { for($j=$i;$j>=1;$j--) { echo $j." "; if($j==1) { echo " "; echo "<br />"; } } } ?>
Output:
6 5 4 3 2 1 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1
2. Program to print Triangle number in reverse pattern
<?php for($i=1;$i<=6;$i++) { for($j=$i;$j>=1;$j--) { echo $j." "; if($j==1) { echo " "; echo "<br />"; } } } ?>
Output:
1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1
33333
6666
999
1212
15
give this pattern.
Hello Tanvi Parekh,
Please try this code:
Hello sir,
1 2 3 4
8 7 6 5
9 10 11 12
16 15 14 13
give me this pattern ans.
Hello Vishal,
Try this code –
hello sir
6,1,1,1,1,1
2,4,2,2,2,2
1,1,6,1,1,1
2,2,2,4,2,2
1,1,1,1,6,1
2,2,2,2,2,4
give me this pattern ans.
Dear Siva,
Thank you so much for the useful solution.
1
2 6
3 7 10
4 8 11 13
5 9 12 14
give php code it.please help
Try this code –
A
C D
G H I
M N O P
U V W X Y
can you explain the PHP code for this pattern and hw it works?
Try this code –
Thanku so much…😊
You’re welcome. Happing Coding.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Plz sir give me answer in php
write a program in php sir
1 5 9
2 6 10
3 7 11
4 8 12
Give me this patten answer. Sir help plss
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5