-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1102.php
More file actions
35 lines (27 loc) · 757 Bytes
/
1102.php
File metadata and controls
35 lines (27 loc) · 757 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
<?php
function simpleMultiplication(int $number): int
{
return ($number % 2) === 0 ? ($number * 8) : ($number * 9);
}
echo simpleMultiplication(2);
function odd_or_even(array $a): string
{
// echo array_sum($a);
count($a) === 0 ? array_push($a, 0) : '';
return (array_sum($a) % 2 === 0) ? "even" : "odd";
}
echo odd_or_even([-1, -3, 5]);
function centuryFromYear1(int $year): int
{
$str = (string) $year;
// var_dump($str);
// echo substr($str, 2, 4);
// echo substr($str, 0, 2);
return (substr($str, 2, 4) == "00") ? (int) substr($str, 0, 2) : (int) (substr($str, 0, 2) + 1);
}
echo centuryFromYear1(672615);
function centuryFromYear(int $year): int
{
return ceil($year / 100);
}
echo centuryFromYear(1201);