Numbers in base-16 representation that cannot be written with decimal digits: Difference between revisions

m
Move Raku to correct spot
m (→‎{{header|Go}}: Iteration now starts at 1)
m (Move Raku to correct spot)
Line 37:
 
42 such numbers found.
</pre>
 
=={{header|REXX}}==
<lang rexx>/*REXX pgm finds positive integers when shown in hex that can't be written with dec digs*/
parse arg n cols . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n = 500 /*Not specified? Then use the default.*/
if cols=='' | cols=="," then cols= 10 /* " " " " " " */
w= 10 /*width of a number in any column. */
title= " positive integers when shown in hexadecimal that can't be written with" ,
'decimal digits, where N < ' n
say ' index │'center(title, 1 + cols*(w+1) ) /*display the title for the output. */
say '───────┼'center("" , 1 + cols*(w+1), '─') /* " a sep " " " */
found= 0; y= 0123456789; idx= 1 /*define a set of forbidden glyphs. */
$= /*list of numbers found (so far). */
do j=1 for n-1 /*find ints in hex with no dec. digits.*/
if verify(y, d2x(j), 'M')\==0 then iterate /*Any dec. digs in hex number? Skip. */ /* ◄■■■■■■■■ the filter. */
found= found + 1 /*bump number of found such numbers. */
$= $ right(j, w) /*add the found number ───► $ list. */
if found // cols \== 0 then iterate /*have we populated a line of output? */
say center(idx, 7)'│' substr($, 2); $= /*display what we have so far (cols). */
idx= idx + cols /*bump the index count for the output*/
end /*j*/
 
if $\=='' then say center(idx, 7)"│" substr($, 2) /*possible display residual output.*/
say '───────┴'center("" , 1 + cols*(w+1), '─') /*display the foot sep for output. */
say
say 'Found ' found title
exit 0 /*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
index │ positive integers when shown in hexadecimal that can't be written with decimal digits, where N < 500
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 10 11 12 13 14 15 170 171 172 173
11 │ 174 175 186 187 188 189 190 191 202 203
21 │ 204 205 206 207 218 219 220 221 222 223
31 │ 234 235 236 237 238 239 250 251 252 253
41 │ 254 255
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────
 
Found 42 positive integers when shown in hexadecimal that can't be written with decimal digits, where N < 500
</pre>
 
Line 142 ⟶ 102:
 
Count: 42</pre>
 
=={{header|REXX}}==
<lang rexx>/*REXX pgm finds positive integers when shown in hex that can't be written with dec digs*/
parse arg n cols . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n = 500 /*Not specified? Then use the default.*/
if cols=='' | cols=="," then cols= 10 /* " " " " " " */
w= 10 /*width of a number in any column. */
title= " positive integers when shown in hexadecimal that can't be written with" ,
'decimal digits, where N < ' n
say ' index │'center(title, 1 + cols*(w+1) ) /*display the title for the output. */
say '───────┼'center("" , 1 + cols*(w+1), '─') /* " a sep " " " */
found= 0; y= 0123456789; idx= 1 /*define a set of forbidden glyphs. */
$= /*list of numbers found (so far). */
do j=1 for n-1 /*find ints in hex with no dec. digits.*/
if verify(y, d2x(j), 'M')\==0 then iterate /*Any dec. digs in hex number? Skip. */ /* ◄■■■■■■■■ the filter. */
found= found + 1 /*bump number of found such numbers. */
$= $ right(j, w) /*add the found number ───► $ list. */
if found // cols \== 0 then iterate /*have we populated a line of output? */
say center(idx, 7)'│' substr($, 2); $= /*display what we have so far (cols). */
idx= idx + cols /*bump the index count for the output*/
end /*j*/
 
if $\=='' then say center(idx, 7)"│" substr($, 2) /*possible display residual output.*/
say '───────┴'center("" , 1 + cols*(w+1), '─') /*display the foot sep for output. */
say
say 'Found ' found title
exit 0 /*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
index │ positive integers when shown in hexadecimal that can't be written with decimal digits, where N < 500
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 10 11 12 13 14 15 170 171 172 173
11 │ 174 175 186 187 188 189 190 191 202 203
21 │ 204 205 206 207 218 219 220 221 222 223
31 │ 234 235 236 237 238 239 250 251 252 253
41 │ 254 255
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────
 
Found 42 positive integers when shown in hexadecimal that can't be written with decimal digits, where N < 500
</pre>
 
=={{header|Ring}}==
10,333

edits