Numbers in base-16 representation that cannot be written with decimal digits: Difference between revisions
Content added Content deleted
(Created page with "{{Draft task}} ;Task: Find numbers in base-16 representation that cannot be written with decimal digits, where '''n < 500''' <br><br> =={{header|Ring}}== <lang ring> see "w...") |
(Added Wren) |
||
Line 52: | Line 52: | ||
Found 42 numbers |
Found 42 numbers |
||
done... |
done... |
||
</pre> |
|||
=={{header|Wren}}== |
|||
{{libheader|Wren-fmt}} |
|||
<lang ecmascript>import "/fmt" for Conv, Fmt |
|||
var decimal = "0123456789" |
|||
var c = 0 |
|||
for (i in 0..499) { |
|||
var hex = Conv.hex(i) |
|||
if (!hex.any { |c| decimal.contains(c) }) { |
|||
Fmt.write("$3s ", i) |
|||
c = c + 1 |
|||
if (c % 14 == 0) System.print() |
|||
} |
|||
} |
|||
System.print("\n%(c) such numbers found.")</lang> |
|||
{{out}} |
|||
<pre> |
|||
10 11 12 13 14 15 170 171 172 173 174 175 186 187 |
|||
188 189 190 191 202 203 204 205 206 207 218 219 220 221 |
|||
222 223 234 235 236 237 238 239 250 251 252 253 254 255 |
|||
42 such numbers found. |
|||
</pre> |
</pre> |
Revision as of 09:38, 24 June 2021
Numbers in base-16 representation that cannot be written with decimal digits is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
- Task
- Find numbers in base-16 representation that cannot be written with decimal digits, where n < 500
Ring
<lang ring> see "working..." + nl see "Numbers in base-16 representation that cannot be written with decimal digits:" + nl
row = 0 baseList = "ABCDEF" limit = 500
for n = 1 to limit
flag = 1 hex = upper(hex(n)) for m = 1 to len(hex) ind = substr(baseList,hex[m]) if ind < 1 flag = 0 exit ok next if flag = 1 see "" + n + " " row = row + 1 if row%5 = 0 see nl ok ok
next
see nl + "Found " + row + " numbers" + nl see "done..." + nl </lang>
- Output:
working... Numbers in base-16 representation that cannot be written with decimal digits: 10 11 12 13 14 15 170 171 172 173 174 175 186 187 188 189 190 191 202 203 204 205 206 207 218 219 220 221 222 223 234 235 236 237 238 239 250 251 252 253 254 255 Found 42 numbers done...
Wren
<lang ecmascript>import "/fmt" for Conv, Fmt
var decimal = "0123456789" var c = 0 for (i in 0..499) {
var hex = Conv.hex(i) if (!hex.any { |c| decimal.contains(c) }) { Fmt.write("$3s ", i) c = c + 1 if (c % 14 == 0) System.print() }
} System.print("\n%(c) such numbers found.")</lang>
- Output:
10 11 12 13 14 15 170 171 172 173 174 175 186 187 188 189 190 191 202 203 204 205 206 207 218 219 220 221 222 223 234 235 236 237 238 239 250 251 252 253 254 255 42 such numbers found.