-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculate.php
More file actions
52 lines (46 loc) · 1.37 KB
/
calculate.php
File metadata and controls
52 lines (46 loc) · 1.37 KB
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
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://siwhitehouse.co.uk/stickers/serendipity/style/css/style.css">
</head>
<body>
<div id="header" align="center">
<h1>The Got - Got - Need Machine</h1>
</div>
<div id="results" style="text-align:center">
<h2>
<?php
/*
Initialise variables
*/
$total = $_POST['total'];
$stickers = $_POST['stickers'];
$swaps = $_POST['swaps'];
$remainder = $total - $stickers;
$potential_remainder = $total-$stickers-$swaps;
$expected = 0;
$y= round($total*(log($total) + 0.5772156649)+0.5);
echo "To collect a full set of $total stickers you should expect to have to buy ";
echo "$y stickers, without swapping";
echo "<br>";
echo "You already have $stickers stickers. To get the remaining $remainder stickers you should expect to buy ";
echo round (portion($remainder, $total));
echo " more stickers.";
echo "<br>";
echo "But, if you successfully swapped the $swaps stickers you've got spare, you'd only have ";
echo $potential_remainder;
echo " left to collect";
echo "<br>";
echo "To get those, you'd only expect to have to buy ";
echo round(portion($potential_remainder, $total));
echo " more stickers. <br> Best get swapping!";
function portion ($remainder, $total){
for ($x=$remainder; $x>=1; $x--) {
$expected = $expected + ($total/$x);
}
return $expected;
}
?>
</h2>
</div>
</body>
</html>