貌似现在有些公司招聘用 ProjectEuler 上的题目出题啊。比如这个
http://projecteuler.net/index.php?section=problems&id=5
2520 is the smallest number that can be divided by each of the numbers
from 1 to 10 without any remainder.
What is the smallest number that is evenly divisible by all of the
numbers from 1 to 20?
某囧人给的答案
http://thedailywtf.com/Articles/Out-of-All-the-Possible-Answers.aspx
"When we interview people," cablecar wrote on the Sidebar, "we give
them simple programming tasks to test their ability. The below code
was an attempt to solve a problem I found on Project Euler. It's from
a candidate for a senior development position with '10 years of PHP'
experience.
for ($i=1;$i<=99999999999;$i++) {
$num = 20*$i;
if ($num%19 == 0) {
if ($num%18 == 0) {
if ($num%17 == 0) {
if ($num%16 == 0) {
if ($num%15 == 0) {
if ($num%14 == 0) {
if ($num%13 == 0) {
if ($num%12 == 0) {
if ($num%11 == 0) {
if ($num%9 == 0) {
if ($num%8 == 0) {
if ($num%7 == 0) {
if ($num%6 == 0) {
if ($num%3 == 0) {
echo $num;
exit();
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
"Yeah, it works, but..."