Today you need to solve a very practical problem: How many loops do you need to have a certain number of sheets on your toilet paper roll? Let's look at some facts:
- The diameter of a bare toilet paper cylinder is 3.8cm
- The length of one sheet of toilet paper is 10cm.
- The thickness of one sheet of toilet paper is 1mm.
Before you wrap around the cylinder the first time, it has a circumference in cm of 3.8*pi. Every time you wrap a sheet around the cylinder its radius increases by .1, therefore its circumference increases by .2*PI. Use this information to find out how many loops it takes to fit n sheets of toilet paper. (Note: Use an approximation of Pi that is at least as accurate as 3.14159).
Test Cases:
n=1:
- 10/(3.8*pi) = .838 loops
n=2:
- (How many full loops can we make?) 1 full loop = 3.8*pi = 11.938.
- (How much do we have left after the 1st loop?) 20 - 11.938 = 8.062
- (How much of a 2nd loop does the remaining piece make?) 8.062/(4*pi) = .642 loops
- Answer: 1.642 loops
n=3:
- 1st full loop = 3.8*pi = 11.938, 2nd full loop = 4*pi = 12.566
- 30 - 11.938 - 12.566 = 5.496
- 5.496/(4.2*pi) = .417
- Answer: 2.417 loops
n=100 => 40.874
nloops = sqrt(n+11.34)*0.0564189 - 0.19
\$\endgroup\$100
->40.874
\$\endgroup\$