Chocolate Math
First of all, pick the number of times a week that you would like to have chocolate. (try for more than once but less than 10).
Multiply this number by 2 (just to be bold)
Add 5
Multiply it by 50
If you have already had your birthday this year -- add 1751 ...
If you haven''t, add 1750 ...
Now subtract the four digit year that you were born
( if you remember)
You should have a three digit number.
The first digit of this was you original number (i.e., how many times you want to have chocolate each week)
The next two numbers are your age.
This is the only year (2001) it will work.
This is a fun math trick that works only for the year 2001. Here's an example PHP code that implements it:
<!DOCTYPE html>
<html>
<head>
<title>Chocolate Math</title>
</head>
<body>
<h1>Chocolate Math</h1>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<label for="chocolate">Number of times per week you want to have chocolate:</label>
<input type="number" id="chocolate" name="chocolate" min="1" max="9"><br><br>
<input type="submit" value="Calculate">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$chocolate = $_POST["chocolate"];
$result = (($chocolate * 2) + 5) * 50;
if (date("md") >= "0422") {
$result += 1751;
} else {
$result += 1750;
}
$result -= $_POST["birth_year"];
$original_number = $chocolate;
$age = substr($result, -2);
echo "<p>Your original number was: " . $original_number . "</p>";
echo "<p>Your age is: " . $age . "</p>";
echo "<p>The number you calculated is: " . $result . "</p>";
}
?>
</body>
</html>
This code creates a form that asks the user to input the number of times per week they want to have chocolate and their birth year. When the user submits the form, the values are passed to the server using the POST method. The PHP code then calculates the result using the steps in the Chocolate Math trick and displays the original number, the age, and the calculated number.
Note that this is just an example and you should customize it to fit your specific needs. Also, remember that this trick only works for the year 2001, so you might want to update the code to reflect that if you plan to use it in a different year.