-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp6.php
More file actions
executable file
·39 lines (33 loc) · 873 Bytes
/
php6.php
File metadata and controls
executable file
·39 lines (33 loc) · 873 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
<html>
<body>
<!-- MADE BY CHETAN KHANNA -->
<!-- ROLL NUMBER : 2018CSC10143 -->
<!-- SEM IV -->
<h3>Check a sequence of numbers is an arithmetic progression or not</h3>
<?php
function AP()
{
$s = explode(",",$_POST['st']);
$d = (int) $s[1] - (int) $s[0];
for ($i = 1; $i < count($s); $i++) {
if ((int) $s[$i] - (int) $s[$i - 1] != $d) {
echo $_POST['st'] . " is not an Arithmetic Progression";
exit();
}
}
echo $_POST['st'] . " is an Arithmetic Progression";
}
if (isset($_POST['submit'])) {
AP();
} else {
?>
<form action="" method="post">
Sequence : <input type="text" name="st" placeholder="1,2,3,4,5" required><br><br>
<span>    </span>
<input type="submit" value="Submit" name="submit">
</form>
<?php
}
?>
</body>
</html>