First attempt at problem 2
Changed variable declaration and indentation
Fixed infinite loop
Changed while loop params
Fixed mistake with loop calculation