-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfizzbuzz.php
51 lines (45 loc) · 863 Bytes
/
fizzbuzz.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?php include 'headers.php'; ?>
</head>
<body>
<?php include 'menu1.php'; ?>
<?php
@include_once 'cronometro.php';
function fizzBuzz ($numero)
{
if ($numero % 3 == 0)
{
$retorno = 'Fizz';
}
if ($numero % 5 == 0)
{
$retorno = 'Buzz';
}
if ($numero % 5 != 0 && $numero % 3 != 0)
{
$retorno = $numero;
}
return $retorno;
}
$limite = mt_rand(1, 200);
$saida = $limite . '<br><hr><br>';
for ($i = 1; $i <= $limite; $i++)
{
$saida .= fizzBuzz($i);
if ($i == $limite) {
$saida .= '.';
}
else
{
$saida .= ', ';
}
}
echo $saida;
?>
<?php include 'menu2.php'; ?>
</body>
</html>