PHP Tutorial

PHP Home

PHP Functions

PHP String Functions

PHP Interview Programs

PHP Common ProgramsPHP Array ProgramsPHP Converter ProgramsPHP Star Patterns ProgramPHP Number Patterns ProgramPHP Alphabet Patterns Program

PHP Reference

ASCII Table

PHP Number Pattern 41

Last Updated:

PHP Number Pattern 41

Try to print the following number pattern using PHP.

Print This Output
                  1
              4   9  16
         25  36  49  64  81
    100 121 144 169 196 225 256
289 324 361 400 441 484 529 576 625

Source Code

PHP Compiler
<?php $m = 1; for($i=1; $i<=9; $i+=2) { for($j=$i; $j<9; $j++) echo "&nbsp;&nbsp;&nbsp;&nbsp;"; for($k=1; $k<=$i; $k++) { echo "<div>". $m*$m ."</div>"; $m++; } echo "<br>"; } ?>

Share this Page

Meet the Author