-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp5.php
More file actions
executable file
·41 lines (37 loc) · 850 Bytes
/
php5.php
File metadata and controls
executable file
·41 lines (37 loc) · 850 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
<html>
<body>
<!-- MADE BY CHETAN KHANNA -->
<!-- ROLL NUMBER : 2018CSC10143 -->
<!-- SEM IV -->
<h3>Check whether a number is a hamming number</h3>
<?php
function check_hamming($x, $y)
{
if ($x == 1) {
echo $y . " is a Hamming Number";
exit();
}
if ($x % 2 == 0) {
check_hamming($x / 2, $y);
}
if ($x % 3 == 0) {
check_hamming($x / 3, $y);
}
if ($x % 5 == 0) {
check_hamming($x / 5, $y);
}
echo $y . " is not a Hamming Number";
exit();
}
if (isset($_POST['submit'])) {
check_hamming($_POST['n'], $_POST['n']);
} else {
?>
<form action="" method="post">
Number : <input type="number" name="n" required><br><br>
<span>    </span>
<input type="submit" value="Submit" name="submit">
</form>
<?php
}
?>