There are 100 doors in a row that are all initially closed.

You make 100 [[task feature::Rosetta Code:multiple passes|passes]] by the doors.

The first time through, visit every door and &nbsp;''toggle''&nbsp; the door &nbsp;(if the door is closed, &nbsp;open it; &nbsp; if it is open,&nbsp; close it).

The second time, only visit every 2<sup>nd</sup> door &nbsp; (door #2, #4, #6, ...), &nbsp; and toggle it.

The third time, visit every 3<sup>rd</sup> door &nbsp; (door #3, #6, #9, ...), etc, &nbsp; until you only visit the 100<sup>th</sup> door.


;Task:
Answer the question: &nbsp; what state are the doors in after the last pass? &nbsp; Which are open, which are closed?


'''[[task feature::Rosetta Code:extra credit|Alternate]]:'''
As noted in this page's &nbsp; [[Talk:100 doors|discussion page]], &nbsp; the only doors that remain open are those whose numbers are perfect squares.

Opening only those doors is an &nbsp; [[task feature::Rosetta Code:optimization|optimization]] &nbsp; that may also be expressed;
however, as should be obvious, this defeats the intent of comparing implementations across programming languages.
<br><br>
