I recently read an article in the paper version (how old fashioned!) of Wired that told how you could impress friends and colleagues with a simple number trick:
Get someone to think of a number, ask them to double it, add 12, halve it, then subtract the number that they started with. You can then amaze them by telling them that the answer is 6!
Obviously I wanted to prove this theory so I knocked up a PowerShell script that does the same calculation for each number between 1-100000 (it was originally a one-liner but I added line breaks here for readability)…
$y=1;
do{$x=((($y*2)+12)/2)-$y;"Start with $y, end up with $x";$y++}
while ($y -le 100000)
Okay, so it’s not the most useful bit of PS but at least you’ve got a bit of mathematical magic to impress people with…
No comments:
Post a Comment