Jump to content

Hard math question


Iggy

Recommended Posts

Posted

there are 1000 lockers and 1000 people, the 1st person opens ever locker, the second person changes every other locker (2,4,6,8) was (if it was open it is now closed), the 3rd person changes every 3rd locker, and the 4th person changes every 4th locker, and so on to all 1000 pll do it.how many fucking lockers are open at the end????????

(i kno teh answer just to tell u this is a 6th grade math question)

this is just to stump ppl

EDIT: another example, if its the 31st person hed change every 31st locker which is locker 31,62,and 93)

Posted

I am bored and should be going to sleep in the morning, so i'll write a script that'll calculate it out in a sec...

***

<?php

/*
1000 lockers, 1000 people. 1st opens all lockers, 2nd opens 2,4,6,
3rd 3,6,9 etc until 1000 people open lockers. how many have been opened?
*/

$i = 1;

while ($i != 1001) {
$a = $a + $i;

if ($a < 1001) {
	++$z;
} else {
	$a = 0;
	++$i;
}
}

die("$z");

?>

Answer: 7069.

But the real answer is 1000, because if you have 1000 lockers to open, the first person would have already opened them all. Since there was no close routine, the second person wouldn't have anything to open, etc. :)

Posted

Oops, sorry, read the question wrong ;) NOW I understand. Writing a new script... :)

<?php

$debug = 0;

while ($i != 1001) {
++$i;
$p = 0;

while ($p < 1001) {
	$p = $p + $i;
	$z = $a[$p];

	if ($z) {
		$z = "0";
	} else {
		$z = "1";
	}

	$a[$p] = $z;

}

if ($debug) {
	$c = "";
	while ($d != 1000) {
		$c = "$c$a[$d]";
		++$d;
	}

	echo "$c
";
	$d = 0;
}
}

while ($b != 1000) {
if ($a[$b] == "1") {
	++$total;
}

$z = "$z$a[$b]";

++$b;
}

echo "Locker Status: $z
";
echo "Total Open: $total
";
echo "Total Closed: ".(1000 - $total)."";

?>

So the answer is 31 open lockers... wish I read it right to begin with :P

Posted

No lockers are open at the end, person number 5 throws a twinky to the end of the hall and a fat kid runs after it, shutting all the locker doors with his immense bulk. :P

Posted

god im tired my ass hurt my brain hurts my tessticals hurt.YAWN....OW.im..............going.................to.................bed.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...