-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecursivClass.php
59 lines (55 loc) · 1.63 KB
/
RecursivClass.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
52
53
54
55
56
57
58
59
<?php
/**
* Created by PhpStorm.
* User: dobrodeev
* Date: 06.08.2018
* Time: 16:35
*/
class RecursivClass
{
public function factorialRecursic($number)
{
if ($number == 1) return 1;
else return ($number * $this->factorialRecursic($number - 1));
}
public function factorialFor($number)
{
$factorial = 1;
for ($i = 1; $i <= $number; $i++) {
$factorial *= $i;
}
echo $number . '! = ' . $factorial . '<br>';
}
/**
* Degrees Celsius Degrees Fahrenheit
* F = 9 / 5 x C + 32
*/
public function degreesExchange()
{
$Fahrenheit = 0;
$j = 0;
echo '<b>Exchange Deegrees Celsius to Fahrengeit</b><br>';
for ($i = 0; $i <= 30; $i++) {
$Fahrenheit = 9 / 5 * $j + 32;
echo $j . ' Celsius -> ' . $Fahrenheit . ' F<br>';
$j += 10;
}
}
/**
* Degrees Celsius Degrees Fahrenheit with parametrs
*/
public function degreesExchangeParametrs($start, $step, $num_rows)
{
// $Fahrenheit = 0;
echo "<b>Exchange Deegrees Celsius to Fahrengeit with step $step</b><br>";
echo '<table border="1">';
echo '<tr><th>Цельсий </th><th>Фаренгейт</th></tr>';
for ($C = $start; $C < $start + $step * $num_rows; $C += $step) {
// $Fahrenheit = 9 / 5 * $start + 32;
// echo '<tr><td>'.$start.' Celsius </td><td>'.$Fahrenheit.' F</td></tr>';
// $start += $step;
echo '<tr><td>' . $C . ' Celsius </td><td>' . (9 / 5 * $C + 32) . ' F</td></tr>';
}
echo '</table>';
}
}