Jump to content

Square-free integers: Difference between revisions

add RPL
(added Arturo)
(add RPL)
Line 2,665:
 
The number of square─free numbers between 1 and 1000000 (inclusive) is: 607926
</pre>
 
=={{header|RPL}}==
{{trans|Python}}
≪ DUP √ CEIL → n max
≪ 1 SF
2 max '''FOR''' root
'''IF''' n root SQ MOD NOT '''THEN''' 1 CF max 'root' STO '''END'''
'''NEXT'''
1 FS?
≫ ≫ '<span style="color:blue">SQFREE?</span>' STO
≪ {} ROT ROT '''FOR''' n '''IF''' n <span style="color:blue">SQFREE?</span> '''THEN''' n + '''END NEXT'''
≫ '<span style="color:blue">TASK1</span>' STO
≪ 0 ROT ROT '''FOR''' n '''IF''' n <span style="color:blue">SQFREE?</span> '''THEN''' 1 + '''END NEXT'''
≫ '<span style="color:blue">TASK2</span>' STO
 
1 145 <span style="color:blue">TASK1</span>
1 1000 <span style="color:blue">TASK2</span>
{{out}}
<pre>
2: { 1 2 3 5 6 7 10 11 13 14 15 17 19 21 22 23 26 29 30 31 33 34 35 37 38 39 41 42 43 46 47 51 53 55 57 58 59 61 62 65 66 67 69 70 71 73 74 77 78 79 82 83 85 86 87 89 91 93 94 95 97 101 102 103 105 106 107 109 110 111 113 114 115 118 119 122 123 127 129 130 131 133 134 137 138 139 141 142 143 145 }
1: 608
</pre>
 
1,150

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.