Home > php教程 > php手册 > php 打印乘法口绝表代码

php 打印乘法口绝表代码

WBOY
Release: 2016-05-25 16:46:35
Original
1159 people have browsed it

PHP是老师经常会要我们做这个的题目,今天我再做一次打印乘法口决,PHP代码如下:

<?php
/*
 *打印乘法口绝表
*/
echo "九灵九乘法口绝表<br><br><br>";
echo "<table>";
for ($i = 1; $i <= 9; $i++) {
    echo "<tr>";
    for ($j = 1; $j <= $i; $j++) {
        echo "<td>" . $j . "*" . $i . "=" . ($j * $i) . "</td>";
    }
    echo "</tr>";
}
echo "</table>";
echo "<br><br><br><br><br><br>";
echo "<table>";
for ($i = 1; $i <= 9; $i++) {
    echo "<tr>";
    for ($j = $i; $j <= 9; $j++) {
        echo "<td>" . $i . "*" . $j . "=" . ($j * $i) . "</td>";
    }
    echo "</tr>";
}
echo "</table>";
?>
Copy after login

一个简单的求和

<?php
function sum($n) {
    if ($n > 1) {
        return sum($n - 1) + $n;
    } else {
        return 1;
    }
}
echo sum(100);
?>
Copy after login


文章网址:

随意转载^^但请附上教程地址。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template