-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14.php
More file actions
44 lines (37 loc) · 792 Bytes
/
14.php
File metadata and controls
44 lines (37 loc) · 792 Bytes
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
<?php
function recurs($num)
{
if($num != 0)
{
echo "a função apresenta o valor $num<br/>";
recurs($num - 1);
}
}
recurs(10);
echo "<br/><hr/><br/>";
// 4! = 4x3x2x1 = 24
function fat($num) // fatorial
{
if($num < 0)
{
return -1;
}
if($num <=1)
{
return 1;
}
return $num * fat($num - 1);
}
echo "Fatorial de 10: ".fat(10);
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>14 aula de PHP - funções recursivas</title>
</head>
<body>
</body>
</html>