document.write( "Question 1209438: The hundred-handed monster Briareus was hungry and attacked a flock of 98 sheep. He didn't want to eat them all, so he developed a strange way to decide which ones to eat. With his hundred hands he lined the sheep up in front of him and attached tags labeling the sheep from 1 to 98, from left to right. First he crammed all the sheep into his mouth. Then he spat out all the even-numbered sheep. Then for every sheep with a number divisible by three, he stuffed it into his mouth if it was outside or spat it out if it was already inside. He did the same for every sheep with a number divisible by 4, 5, and so on up to 98. At the end, he devoured the sheep that were left in his mouth. How many sheep were left in the flock after Briareus left?
\n" ); document.write( "CC12#3
\n" ); document.write( "
\n" ); document.write( "

Algebra.Com's Answer #848860 by math_tutor2020(3817)\"\" \"About 
You can put this solution on YOUR website!

\n" ); document.write( "Answer: 89 sheep\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Explanation\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "This problem is practically identical to the locker problem
\n" ); document.write( "https://math.stackexchange.com/questions/2017047/the-locker-problem-why-squares
\n" ); document.write( "and also the light switch problem
\n" ); document.write( "https://math.hmc.edu/funfacts/toggling-light-switches/
\n" ); document.write( "They are basically the same idea just with a different coat of paint so to speak.\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Any non-perfect square has an even number of factors. This leads to an even number of swaps.
\n" ); document.write( "For instance sheep number 6 goes free since it has four swaps (due to the four factors 1,2,3,6)
\n" ); document.write( "This sheep starts outside and ends outside. \r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Any perfect square has an odd number of factors, so those sheep numbers have an odd number of swaps.
\n" ); document.write( "Those unfortunate sheep start outside the mouth and end up eaten. \r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "There are 9 perfect squares between 1 and 98 since 9^2 = 81 is the largest perfect square of the list.
\n" ); document.write( "9 sheep are eaten and the other 98-9 = 89 sheep survive.\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "--------------------------------------------------------------------------\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Another approach\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Let's look at a smaller flock say of 10 sheep.
\n" ); document.write( "The monster places all of them into its mouth.
\n" ); document.write( "1, 2, 3, 4, 5, 6, 7, 8, 9, 10\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Erase the even numbers
\n" ); document.write( "1, 3, 5, 7, 9\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Then go through the multiples of 3 between 1 and 10.
\n" ); document.write( "If you find 3, 6, or 9 in that previous list, then erase it.
\n" ); document.write( "Otherwise introduce it back into the list.
\n" ); document.write( "We go from
\n" ); document.write( "1, 3, 5, 7, 9
\n" ); document.write( "to
\n" ); document.write( "1, 5, 6, 7\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Now go through the multiples of 4.
\n" ); document.write( "If you find 4 or 8 in the previous list above then erase it. Otherwise add it in.
\n" ); document.write( "We go from
\n" ); document.write( "1, 5, 6, 7
\n" ); document.write( "to
\n" ); document.write( "1, 4, 5, 6, 7, 8\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Keep this process going until reaching 10.\r
\n" ); document.write( "
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Here's the full process
\n" ); document.write( "\n" ); document.write( "\n" ); document.write( "
RoundSheep In Mouth
11, 2, 3, 4, 5, 6, 7, 8, 9, 10
21, 3, 5, 7, 9
31, 5, 6, 7
41, 4, 5, 6, 7, 8
51, 4, 6, 7, 8, 10
61, 4, 7, 8, 10
71, 4, 8, 10
81, 4, 10
91, 4, 9, 10
101, 4, 9

\n" ); document.write( "We see that the perfect squares remain.
\n" ); document.write( "These sheep are eaten. The others go free.\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Applying this idea to numbers 1 through 98 will show that 1, 4, 9, 16, 25, 36, 49, 64, 81 are eaten.
\n" ); document.write( "There are 9 of those values so 98-9 = 89 sheep go free.
\n" ); document.write( "It might help to make a 10 by 10 grid of numbers from 1 to 100. Cross off 99 and 100 since the list ends with 98.
\n" ); document.write( "
\n" ); document.write( "
\n" );