Jump to content

Forbidden numbers: Difference between revisions

J
(Added Perl)
(J)
Line 280:
Forbidden number count <= 500,000,000: 83,333,328
</pre>
 
=={{header|J}}==
 
For this task we can find forbidden numbers up to some limiting value y:
<syntaxhighlight lang=J>forbid=: {{
s1=. *:i.1+<.%:y
s2=. ~.(#~ y>:]),s1+/s1
s3=. ~.(#~ y>:]),s2+/s1
(1+i.y)-.s1,s2,s3
}}</syntaxhighlight>
 
The task then becomes:
 
<syntaxhighlight lang=J> 5 10$forbid 500
7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
#forbid 500
82
#forbid 5000
831
#forbid 50000
8330
#forbid 500000
83331</syntaxhighlight>
 
=={{header|jq}}==
6,962

edits

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