-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomework_2.php
47 lines (40 loc) · 1 KB
/
homework_2.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
<?php
$arr = range(20, 1000, 37);
function find_3_prime() {
$br=0;
foreach ($GLOBALS['arr'] as $number)
if(IsPrime($number))
{
$br++;
if($br==3)
{
echo "$number</p>";
return;
}
}
}
find_3_prime();
function IsPrime($Num)
{
for($CurrNum = 2; $CurrNum < $Num; $CurrNum++)
if($Num % $CurrNum == 0)
return FALSE;
return TRUE;
}
function check_exists()
{
if(in_array(146, $GLOBALS['arr']))
echo "The number 146 exist in the array </p>";
else
echo "The number 146 does not exist in the array </p>";
if(in_array(284, $GLOBALS['arr']))
echo "The number 284 exist in the array</p>";
else
echo "The number 284 does not exist in the array</p>";
if(in_array(871, $GLOBALS['arr']))
echo "The number 871 exist in the array</p>";
else
echo "The number 871 does not exist in the array</p>";
}
check_exists();
?>