0

I have the following task to solve: I have 100 doors in a row from 1-100. I send 10 persons into the row of doors one after another. The doors are initially opened. first person opens every 5-th door;; 5, 10, 15, 20...100 second person opens every 10-th door; 10, 20, 30 40, 100 third person opens every 15-th door; 15,30 45... 100 This pattern continues until the last person opens door nr: 50 and 100 (50-th doors).

Which doors are closed after everyone have passed? It should output the specific number of doors, (The answer should be 5, 20, 45, 55, 65, 70, 75, 85, 95, 100).

I have tried to solved the issue in Python with the my code displayed underneath. I am now trying to solve it in R, but I have problems with the for loops, I'm not getting the correct answer (I must use for loop statements). Anyone have some suggestions how to solve it?

Code

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Learner
  • 1
  • 1

0 Answers0