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

You make 100 passes by the doors.

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

The second time, only visit every 2nd door   (door #2, #4, #6, ...),   and toggle it.

The third time, visit every 3rd door   (door #3, #6, #9, ...), etc,   until you only visit the 100th door.



Task

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


Alternate:
As noted in this page's   discussion page,   the only doors that remain open are those whose numbers are perfect squares.

Opening only those doors is an   optimization   that may also be expressed;
however, as should be obvious, this defeats the intent of comparing implementations across programming languages.




 
                           00000064  0000     1 n = 100
                               0000  0000     2 .entry	doors, ^m<>
                         26'AF   9F  0002     3 	pushab	b^arr				; offset signed byte
                    50   64 8F   9A  0005     4 	movzbl	#n, r0
                            50   DD  0009     5 	pushl	r0				; (sp) -> .ascid arr
                                     000B     6 10$:
                       51   50   D0  000B     7 	movl	r0, r1				; step = start index
                                     000E     8 20$:
                  25'AF41   01   8C  000E     9 	xorb2	#^a"0" \^a"1", b^arr-1[r1]	; \ xor toggle "1"<->"0"
             FFF5 51   50   6E   F1  0013    10 	acbl	(sp), r0, r1, 20$		; limit, step, index
                         EF 50   F5  0019    11 	sobgtr	r0, 10$				; n..1
                                     001C    12 
                            5E   DD  001C    13 	pushl	sp				; descriptor by reference
              00000000'GF   01   FB  001E    14 	calls	#1, g^lib$put_output		; show result
                                 04  0025    15 	ret
                                     0026    16 
30'30'30'30'30'30'30'30'30'30'30'30' 0026    17 arr:	.byte	^a"0"[n]
30'30'30'30'30'30'30'30'30'30'30'30' 0032       
30'30'30'30'30'30'30'30'30'30'30'30' 003E       
30'30'30'30'30'30'30'30'30'30'30'30' 004A       
30'30'30'30'30'30'30'30'30'30'30'30' 0056       
30'30'30'30'30'30'30'30'30'30'30'30' 0062       
30'30'30'30'30'30'30'30'30'30'30'30' 006E       
30'30'30'30'30'30'30'30'30'30'30'30' 007A       
                        30'30'30'30' 0086       
                                     008A    18 .end	doors
$ run doors
1001000010000001000000001000000000010000000000001000000000000001000000000000000010000000000000000001
 