-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13.php
56 lines (37 loc) · 861 Bytes
/
13.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
<?php
function getExp($num){
$counter = 0;
$i = 1;
if($num < 10)
return 0;
while($num >= $i){
$i *= 10;
$counter++;
}
return $counter - 1;
}
function getNum($num, $pos){//получить число по порядковому номеру
$pos = getExp($num) - $pos;
return ( (int)($num / pow(10, $pos)) ) % 10;
}
function testPalindrom($num){
$sz = getExp($num);
if(!$sz)
return false;
for($i = 0; $i < $sz / 2; $i++){
$num1 = getNum($num, $i);
$num2 = getNum($num, $sz - $i);
if($num1 != $num2){
return false;
}
}
return true;
}
$n = 4;
$m = 10;
$N = 1221;//pow(2, $n) + $m;
$res = false;
if( ( getExp($N) % 2) && testPalindrom($N) )
echo "Симетрично";
else
echo "Не симетрично";