Base 16 numbers needing a to f: Difference between revisions

(add FreeBASIC)
(→‎BQN: add)
 
(27 intermediate revisions by 15 users not shown)
Line 8:
{{trans|Nim}}
 
<langsyntaxhighlight lang="11l">V l = (0..500).filter(n -> !hex(n).is_digit())
 
print(‘Found ’l.len" numbers between 0 and 500:\n")
L(n) l
print(‘#3’.format(n), end' I (L.index + 1) % 19 == 0 {"\n"} E ‘ ’)
print()</langsyntaxhighlight>
 
{{out}}
Line 37:
</pre>
=={{header|68000 Assembly}}==
<langsyntaxhighlight lang="68000devpac">MOVEQ #0,D0 ;clear D0
MOVEM.L D0,D1-D6 ;clear data regs
 
Line 90:
RTS
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</langsyntaxhighlight>
 
=={{header|Action!}}==
<syntaxhighlight lang="action!">BYTE FUNC IsHexWithLetter(INT x)
DO
IF x MOD 16>9 THEN
RETURN (1)
FI
x==/16
UNTIL x=0
OD
RETURN (0)
 
PROC Main()
INT i,count,min=[0],max=[500]
 
count=0
FOR i=min TO max
DO
IF IsHexWithLetter(i) THEN
PrintI(i) Put(32)
count==+1
FI
OD
PrintF("%E%EFound %I numbers between %I and %I",count,min,max)
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Base_16_numbers_needing_a_to_f.png Screenshot from Atari 8-bit computer]
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108
109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268
269 270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348
349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
 
Found 301 numbers between 0 and 500
</pre>
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_Io;
 
procedure Base_16_Numbers is
Line 126 ⟶ 167:
New_Line (2);
Put ("Total count: "); Natural_Io.Put (Count, Width => 3); New_Line;
end Base_16_Numbers;</langsyntaxhighlight>
{{out}}
<pre> 10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63
Line 145 ⟶ 186:
 
=={{header|ALGOL 68}}==
<langsyntaxhighlight lang="algol68">BEGIN # show numbers that when represented in hex, have at least one a-f digit #
INT h count := 0;
FOR i TO 500 DO
Line 159 ⟶ 200:
OD
OD
END</langsyntaxhighlight>
{{out}}
<pre>
Line 181 ⟶ 222:
 
=={{header|ALGOL W}}==
<langsyntaxhighlight lang="algolw">% show numbers that when represented in hex, have at least one a-f digit %
begin
integer hCount;
Line 200 ⟶ 241:
end while_v_gt_0
end for_i
end.</langsyntaxhighlight>
{{out}}
<pre>
Line 223 ⟶ 264:
=={{header|APL}}==
{{works with|Dyalog APL}}
<langsyntaxhighlight APLlang="apl">(⊢(/⍨)(10∨.≤16(⊥⍣¯1)⊢)¨)⍳500</langsyntaxhighlight>
{{out}}
<pre>10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63
Line 247 ⟶ 288:
=={{header|AppleScript}}==
===Procedural===
<langsyntaxhighlight lang="applescript">local output, n, x, ding
set output to {}
repeat with n from 0 to 500
Line 258 ⟶ 299:
if (ding) then set end of output to n
end repeat
return output</langsyntaxhighlight>
 
{{output}}
<langsyntaxhighlight lang="applescript">{10, 11, 12, 13, 14, 15, 26, 27, 28, 29, 30, 31, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 74, 75, 76, 77, 78, 79, 90, 91, 92, 93, 94, 95, 106, 107, 108, 109, 110, 111, 122, 123, 124, 125, 126, 127, 138, 139, 140, 141, 142, 143, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 266, 267, 268, 269, 270, 271, 282, 283, 284, 285, 286, 287, 298, 299, 300, 301, 302, 303, 314, 315, 316, 317, 318, 319, 330, 331, 332, 333, 334, 335, 346, 347, 348, 349, 350, 351, 362, 363, 364, 365, 366, 367, 378, 379, 380, 381, 382, 383, 394, 395, 396, 397, 398, 399, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500}</langsyntaxhighlight>
 
===Functional===
Defining a simple predicate, and composing a test with formatted output from a set of generic functions:
<langsyntaxhighlight lang="applescript">-------- INTEGERS NEEDING HEX DIGITS HIGHER THAN 9 -------
 
-- p :: Int -> Bool
Line 465 ⟶ 506:
end repeat
v
end |until|</langsyntaxhighlight>
{{Out}}
<pre>301 matches for the predicate:
Line 520 ⟶ 561:
494 495 496 497 498 499
500</pre>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="rebol">needsAF?: function [x][
hex: as.hex x
loop `a`..`f` 'c [
if contains? hex c ->
return true
]
return false
]
 
print select 0..500 => needsAF?</syntaxhighlight>
 
{{out}}
 
<pre>10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f BASE-16_REPRESENTATION.AWK
BEGIN {
Line 535 ⟶ 593:
exit(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 558 ⟶ 616:
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
<lang basic>10 DEFINT I,J
<syntaxhighlight lang="qbasic">function needs_af (n)
20 FOR I=1 TO 500
while n > 0
30 J=I
if (n % 16) > 9 then return true
40 IF (J AND 15)>=10 THEN PRINT I, ELSE J=J/16: IF J>9 THEN 40
n = n \ 16
50 NEXT I</lang>
end while
return false
end function
 
for i = 1 to 500
if needs_af(i) then print i; " ";
next i
end</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">function needs_af( byval n as uinteger ) as boolean
while n>0
if n mod 16 > 9 then return true
n\=16
wend
return false
end function
 
for i as uinteger = 1 to 500
if needs_af(i) then print i;" ";
next i
</syntaxhighlight>
{{out}}<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
</pre>
 
==={{header|Gambas}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vbnet">Public Sub Main()
For i As Integer = 1 To 500
If needs_af(i) Then Print i; " ";
Next
End
 
Function needs_af(n As Integer) As Boolean
 
While n > 0
If n Mod 16 > 9 Then Return True
n \= 16
Wend
Return False
 
End Function</syntaxhighlight>
 
==={{header|GW-BASIC}}===
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|MSX_BASIC}}
<syntaxhighlight lang="gwbasic">10 DEFINT I,J
20 FOR I = 1 TO 500
30 J = I
40 IF (J AND 15) >= 10 THEN PRINT I, ELSE J = J / 16: IF J > 9 THEN 40
50 NEXT I</syntaxhighlight>
{{out}}
<pre style='height:50ex'> 10 11 12 13 14
Line 625 ⟶ 741:
493 494 495 496 497
498 499 500</pre>
 
==={{header|MSX Basic}}===
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
==={{header|QuickBASIC}}===
{{trans|Modula-2}}
<syntaxhighlight lang="qbasic">
REM Base 16 numbers needing A to F
DECLARE FUNCTION UsesAToF! (BYVAL N%)
CONST TRUE = -1, FALSE = 0, MAX = 500
Count% = 0
FOR N% = 1 TO MAX
IF UsesAToF(N%) THEN
PRINT USING "####"; N%;
Count% = Count% + 1
IF Count% MOD 20 = 0 THEN PRINT
END IF
NEXT
PRINT : PRINT
PRINT USING "### numbers found."; Count%
END
 
FUNCTION UsesAToF (BYVAL N%)
WHILE N% > 9
IF N% MOD 16 >= 10 THEN
UsesAToF = TRUE: EXIT FUNCTION
ELSE
N% = N% \ 16
END IF
WEND
UsesAToF = FALSE
END FUNCTION
</syntaxhighlight>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
 
301 numbers found.
</pre>
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
<syntaxhighlight lang="vb">for i = 1 to 500
if needsaf(i) then print i; " ";
next i
end
 
function needsaf(n)
while n > 0
if (n mod 16) > 9 then needsaf = 1 : goto [exit]
n = int(n / 16)
wend
needsaf = 0
[exit]
end function</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|True BASIC}}===
{{trans|QuickBASIC}}
<syntaxhighlight lang="qbasic">FUNCTION usesatof(n)
DO WHILE n > 9
IF REMAINDER(n,16) >= 10 THEN
LET usesatof = True
EXIT FUNCTION
ELSE
LET n = IP(n/16)
END IF
LOOP
LET usesatof = False
END FUNCTION
 
LET True = -1
LET False = 0
LET max = 500
LET count = 0
FOR n = 1 TO ROUND(max)
IF usesatof(n)<>0 THEN
PRINT USING "####": n;
LET count = count+1
IF REMAINDER(count,20) = 0 THEN PRINT
END IF
NEXT n
PRINT
PRINT USING "### numbers found.": count
END</syntaxhighlight>
{{out}}
<pre>Same as QuickBASIC entry.</pre>
 
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">sub needs_af (n)
while n > 0
if mod(n, 16) > 9 then return true : fi
n = int(n / 16)
wend
return false
end sub
 
for i = 1 to 500
if needs_af(i) then print i, " ", : fi
next i
end</syntaxhighlight>
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let nondec(x) =
Line 643 ⟶ 876:
$)
wrch('*N')
$)</langsyntaxhighlight>
{{out}}
<pre> 10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
Line 661 ⟶ 894:
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500</pre>
 
=={{header|BQN}}==
<syntaxhighlight lang="bqn">43‿7 ⥊ / 9 < 16 ⌊∘÷˜•_while_(≤ ∧ 9 ≥ |)¨ ↕501</syntaxhighlight>
{{out}}
<pre>┌─
╵ 10 11 12 13 14 15 26
27 28 29 30 31 42 43
44 45 46 47 58 59 60
61 62 63 74 75 76 77
78 79 90 91 92 93 94
95 106 107 108 109 110 111
122 123 124 125 126 127 138
139 140 141 142 143 154 155
156 157 158 159 160 161 162
163 164 165 166 167 168 169
170 171 172 173 174 175 176
177 178 179 180 181 182 183
184 185 186 187 188 189 190
191 192 193 194 195 196 197
198 199 200 201 202 203 204
205 206 207 208 209 210 211
212 213 214 215 216 217 218
219 220 221 222 223 224 225
226 227 228 229 230 231 232
233 234 235 236 237 238 239
240 241 242 243 244 245 246
247 248 249 250 251 252 253
254 255 266 267 268 269 270
271 282 283 284 285 286 287
298 299 300 301 302 303 314
315 316 317 318 319 330 331
332 333 334 335 346 347 348
349 350 351 362 363 364 365
366 367 378 379 380 381 382
383 394 395 396 397 398 399
410 411 412 413 414 415 416
417 418 419 420 421 422 423
424 425 426 427 428 429 430
431 432 433 434 435 436 437
438 439 440 441 442 443 444
445 446 447 448 449 450 451
452 453 454 455 456 457 458
459 460 461 462 463 464 465
466 467 468 469 470 471 472
473 474 475 476 477 478 479
480 481 482 483 484 485 486
487 488 489 490 491 492 493
494 495 496 497 498 499 500
┘</pre>
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <iomanip>
#include <iostream>
 
Line 685 ⟶ 967:
}
std::cout << "\n\n" << count << " such numbers found.\n";
}</langsyntaxhighlight>
 
{{out}}
Line 713 ⟶ 995:
301 such numbers found.
</pre>
 
=={{header|CLU}}==
<syntaxhighlight lang="clu">nondec = proc (x: int) returns (bool)
while x>9 do
if x//16>=10 then return(true) end
x := x/16
end
return(false)
end nondec
 
start_up = proc ()
po: stream := stream$primary_output()
count: int := 0
for n: int in int$from_to(1,500) do
if nondec(n) then
stream$putright(po, int$unparse(n), 4)
count := count + 1
if count//20=0 then stream$putl(po, "") end
end
end
stream$putl(po, "\nFound " || int$unparse(count) || " numbers.")
end start_up</syntaxhighlight>
{{out}}
<pre> 10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
Found 301 numbers.</pre>
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. BASE-16.
Line 769 ⟶ 1,091:
ELSE
MOVE N16 TO NTEMP
GO TO IS-NONDEC.</langsyntaxhighlight>
{{out}}
<pre> 10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47
Line 792 ⟶ 1,114:
 
=={{header|Cowgol}}==
<langsyntaxhighlight lang="cowgol">include "cowgol.coh";
 
sub nondecimal(n: uint16): (r: uint8) is
Line 821 ⟶ 1,143:
i := i + 1;
end loop;
print_nl();</langsyntaxhighlight>
{{out}}
<pre>10 11 12 13 14 15 26 27 28 29
Line 854 ⟶ 1,176:
490 491 492 493 494 495 496 497 498 499
500</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
An example of using Delphi-style operations using set operators to find hex nibbles A..F
<syntaxhighlight lang="Delphi">
function HasAlphaDigits(W: integer): boolean;
{test if number has A..F in one or more of the digits}
{Only works for numbers up to 9FF or 2559}
begin
Result:=((W and $000F) in [$000A,$000B,$000C,$000D,$000E,$000F]) or
((W and $00F0) in [$00A0,$00B0,$00C0,$00D0,$00E0,$00F0]);
end;
 
procedure HasNibblesAF(Memo: TMemo);
{Find all numbers 1 through 500 where the hex}
{version has A..F in any of the nibbles}
var I,Cnt: integer;
var S: string;
begin
Cnt:=0;
S:='';
for I:=1 to 500 do
if HasAlphaDigits(I) then
begin
Inc(Cnt);
S:=S+Format('%4.0d', [I]);
if (Cnt mod 20)=0 then S:=S+#$0D+#$0A;
end;
Memo.Text:=S;
Memo.Lines.Add('Count = '+IntToStr(Cnt));
end;
 
</syntaxhighlight>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
Count = 301
 
</pre>
 
 
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// Base 16 representation: Nigel Galloway. June 3rd., 2021
let rec fN g=match g%16,g/16 with (n,0)->9<n |(n,g) when n<10->fN g |_->true
seq{1..500}|>Seq.filter fN|>Seq.iter(printf "%d "); printfn ""
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 870 ⟶ 1,249:
 
{{works with|Factor|0.99 2021-02-05}}
<langsyntaxhighlight lang="factor">USING: combinators formatting grouping io kernel lists
lists.lazy math prettyprint sequences ;
 
Line 884 ⟶ 1,263:
1 lfrom [ non-decimal? ] lfilter [ 501 < ] lwhile
list>array dup 15 group [ [ "%3d " printf ] each nl ] each nl
length pprint " such numbers found." print</langsyntaxhighlight>
{{out}}
<pre>
Line 911 ⟶ 1,290:
301 such numbers found.
</pre>
The above solution uses lazy computation and tail recursion. Here's an eager solution, but it allocates a lot of intermediate sequences.
<syntaxhighlight lang="factor">USING: formatting kernel math ranges sequences ;
IN: rosetta-code.needs-a..f?
 
: quads ( n -- seq )
[ dup 0 > ] [ 16 /mod ] produce nip ;
 
: needs-a..f? ( n -- ? )
quads [ 9 > ] any? ;
 
500 [1..b] [ needs-a..f? ] filter [ "%d " printf ] each</syntaxhighlight>
{{out}}Same numbers as above, but on a single line.
 
=={{header|FOCAL}}==
<langsyntaxhighlight FOCALlang="focal">01.10 S C=0
01.20 F N=1,500;D 2
01.30 T !
Line 927 ⟶ 1,318:
02.80 S C=C+1
02.90 I (C-10)2.99;T !;S C=0
02.99 R</langsyntaxhighlight>
{{out}}
<pre>= 10= 11= 12= 13= 14= 15= 26= 27= 28= 29
Line 963 ⟶ 1,354:
=={{header|Forth}}==
{{works with|Gforth}}
<langsyntaxhighlight lang="forth">\ Returns true if the hexadecimal representation of n contains at least one
\ non-decimal digit.
: non-decimal ( u -- ? )
Line 988 ⟶ 1,379:
 
main
bye</langsyntaxhighlight>
 
{{out}}
Line 1,017 ⟶ 1,408:
</pre>
 
=={{header|FreeBASICFrink}}==
<syntaxhighlight lang="frink">select[1 to 500, {|n| base16[n] =~ %r/[a-f]/i}]</syntaxhighlight>
<lang freebasic>function needs_af( byval n as uinteger ) as boolean
{{out}}
while n>0
<pre>
if n mod 16 > 9 then return true
[10, 11, 12, 13, 14, 15, 26, 27, 28, 29, 30, 31, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 74, 75, 76, 77, 78, 79, 90, 91, 92, 93, 94, 95, 106, 107, 108, 109, 110, 111, 122, 123, 124, 125, 126, 127, 138, 139, 140, 141, 142, 143, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 266, 267, 268, 269, 270, 271, 282, 283, 284, 285, 286, 287, 298, 299, 300, 301, 302, 303, 314, 315, 316, 317, 318, 319, 330, 331, 332, 333, 334, 335, 346, 347, 348, 349, 350, 351, 362, 363, 364, 365, 366, 367, 378, 379, 380, 381, 382, 383, 394, 395, 396, 397, 398, 399, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500]
n\=16
wend
return false
end function
 
for i as uinteger = 1 to 500
if needs_af(i) then print i;" ";
next i
</lang>
{{out}}<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
</pre>
 
=={{header|Go}}==
{{trans|Wren}}
<langsyntaxhighlight lang="go">package main
 
import (
Line 1,058 ⟶ 1,439:
}
fmt.Printf("\n\n%d such numbers found.\n", c)
}</langsyntaxhighlight>
 
{{out}}
Line 1,088 ⟶ 1,469:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.List (intercalate, transpose)
import Data.List.Split (chunksOf)
import Text.Printf (printf)
Line 1,133 ⟶ 1,514:
 
justifyRight :: Int -> Char -> String -> String
justifyRight n c = (drop . length) <*> (replicate n c <>)</langsyntaxhighlight>
{{Out}}
<pre>301 matches up to 500:
Line 1,158 ⟶ 1,539:
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500</pre>
 
=={{header|J}}==
<syntaxhighlight lang="j">needsAtoF=. (9 +./@:< 16&#.inv)"0
 
_16 echo\ I. needsAtoF i. 501</syntaxhighlight>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45
46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91
92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127
138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315
316 317 318 319 330 331 332 333 334 335 346 347 348 349 350 351
362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397
398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
488 489 490 491 492 493 494 495 496 497 498 499 500
</pre>
 
=={{header|JavaScript}}==
<langsyntaxhighlight lang="javascript">(() => {
"use strict";
 
Line 1,343 ⟶ 1,751:
// MAIN ---
return main();
})();</langsyntaxhighlight>
{{Out}}
<pre>301 matches up to 500:
Line 1,402 ⟶ 1,810:
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<syntaxhighlight lang="jq">
<lang jq>
# decimal number to hex string using lower-case letters
def hex:
def stream:
recurse(if . >= 016 then ./16|floor else empty end) | . % 16 ;
[stream] | reverse
if . == 0 then "0"
else [stream] | reverse | .[1:]
| map(if . < 10 then 48 + . else . + 87 end) | implode
end;
Line 1,428 ⟶ 1,835:
;
task
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,465 ⟶ 1,872:
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">usesletters = filter(n -> begin s = string(n, base = 16); any(c -> c in s, collect("abcdef")) end, 1:500)
 
foreach(p -> print(rpad(p[2], 4), p[1] % 15 == 0 ? "\n" : ""), enumerate(usesletters))
</langsyntaxhighlight>{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44
Line 1,494 ⟶ 1,901:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">Select[Range[500], AnyTrue[IntegerDigits[#, 16], GreaterEqualThan[10]] &]</langsyntaxhighlight>
{{out}}
<pre>{10, 11, 12, 13, 14, 15, 26, 27, 28, 29, 30, 31, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 74, 75, 76, 77, 78, 79, 90, 91, 92, 93, 94, 95, 106, 107, 108, 109, 110, 111, 122, 123, 124, 125, 126, 127, 138, 139, 140, 141, 142, 143, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 266, 267, 268, 269, 270, 271, 282, 283, 284, 285, 286, 287, 298, 299, 300, 301, 302, 303, 314, 315, 316, 317, 318, 319, 330, 331, 332, 333, 334, 335, 346, 347, 348, 349, 350, 351, 362, 363, 364, 365, 366, 367, 378, 379, 380, 381, 382, 383, 394, 395, 396, 397, 398, 399, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500}</pre>
 
=={{header|Modula-2}}==
<syntaxhighlight lang="modula2">MODULE NonDecimal;
FROM InOut IMPORT WriteString, WriteCard, WriteLn;
 
CONST max = 500;
VAR n, count: CARDINAL;
 
PROCEDURE usesAtoF(n: CARDINAL): BOOLEAN;
BEGIN
WHILE n>9 DO
IF n MOD 16 >= 10 THEN
RETURN TRUE;
ELSE
n := n DIV 16;
END;
END;
RETURN FALSE;
END usesAtoF;
 
BEGIN
count := 0;
FOR n := 1 TO max DO
IF usesAtoF(n) THEN
WriteCard(n, 4);
INC(count);
IF count MOD 20 = 0 THEN
WriteLn;
END;
END;
END;
WriteLn;
WriteLn;
WriteCard(count, 3);
WriteString(" numbers found.");
WriteLn;
END NonDecimal.</syntaxhighlight>
{{out}}
<pre> 10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
 
301 numbers found.</pre>
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import strutils, sugar
 
let list = collect(newSeq):
Line 1,508 ⟶ 1,971:
for i, n in list:
stdout.write ($n).align(3), if (i + 1) mod 19 == 0: '\n' else: ' '
echo()</langsyntaxhighlight>
 
{{out}}
Line 1,529 ⟶ 1,992:
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 </pre>
 
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let rec has_xdigit n =
n land 15 > 9 || n > 15 && has_xdigit (n lsr 4)
 
let () =
Seq.(ints 1 |> take 500 |> filter has_xdigit |> map string_of_int)
|> List.of_seq |> String.concat " " |> print_endline</syntaxhighlight>
{{out}}
<pre>10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500</pre>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Base-16_representation
Line 1,537 ⟶ 2,010:
 
print join( ' ', grep sprintf("%x", $_) =~ tr/a-z//, 1 .. 500 ) =~
s/.{71}\K /\n/gr, "\n";</langsyntaxhighlight>
{{out}}
<pre>
Line 1,561 ⟶ 2,034:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">above9</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">return</span> <span style="color: #7060A8;">max</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%x"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span><span style="color: #0000FF;">))></span><span style="color: #008000;">'9'</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">500</span><span style="color: #0000FF;">),</span><span style="color: #000000;">above9</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">sprint</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"found"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">))})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,571 ⟶ 2,044:
</pre>
{{trans|Raku|someone got their clever hat on there}}
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1.0.0"</span><span style="color: #0000FF;">)</span>
Line 1,591 ⟶ 2,064:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">fmt</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">thresh</span><span style="color: #0000FF;">,</span><span style="color: #000000;">can</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cannot</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,605 ⟶ 2,078:
 
=={{header|PL/M}}==
<langsyntaxhighlight lang="plm">100H: /* SHOW NUMBERS THAT WHEN REPRESENTED IN HEX, HAVE AT LEAST 1 A-F DIGIT */
/* CP/M BDOS SYSTEM CALL */
BDOS: PROCEDURE( FN, V ); DECLARE FN BYTE, V ADDRESS; GOTO 5; END;
Line 1,648 ⟶ 2,121:
END;
END;
EOF</langsyntaxhighlight>
{{out}}
<pre>
Line 1,670 ⟶ 2,143:
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">'''Integers needing any alpha digits in hex'''
 
 
Line 1,727 ⟶ 2,200:
# MAIN ---
if __name__ == '__main__':
main()</langsyntaxhighlight>
{{Out}}
<pre>301 matches for the predicate:
Line 1,785 ⟶ 2,258:
=={{header|Quackery}}==
 
<langsyntaxhighlight Quackerylang="quackery"> [ false swap
[ dup 0 != while
16 /mod
Line 1,799 ⟶ 2,272:
[ i^ number$
nested join ] ]
60 wrap$</langsyntaxhighlight>
 
{{out}}
Line 1,832 ⟶ 2,305:
Base 16 is not hexadecimal. Hexadecimal is ''an implementation'' of base 16.
 
<syntaxhighlight lang="raku" perl6line>use Base::Any;
set-digits <⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳ ㉑ ㉒ ㉓ ㉔ ㉕>;
say (7**35).&to-base(16);
 
# ⑭㉒⑱⑩⑰⑰⑳⑮⑱⑳⑩⑳⑱㉒㉑⑰㉒⑫⑭⑲⑯⑩㉔⑮⑰</langsyntaxhighlight>
 
How many of those glyphs are decimal digits? And yet it '''is''' in base 16, albeit with non-standard digit glyphs. So they '''all''' can be written without using a hexadecimal digit.
Line 1,845 ⟶ 2,318:
Bah. Show which when written in base 16, contain a digit glyph with a value greater than 9:
 
<syntaxhighlight lang="raku" perl6line>put display :20cols, :fmt('%3d'), (^501).grep( { so any |.map: { .polymod(16 xx *) »>» 9 } } );
 
sub display ($list, :$cols = 10, :$fmt = '%6d', :$title = "{+$list} matching:\n" ) {
cache $list;
$title ~ $list.batch($cols)».fmt($fmt).join: "\n"
}</langsyntaxhighlight>
{{out}}
<pre>301 matching:
Line 1,872 ⟶ 2,345:
But wait a minute. Let's take another look at the the task title. '''Base-16 representation'''. It isn't talking about Base 16 at all. It's talking about Base'''-16'''... so let's do it in base -16.
 
<syntaxhighlight lang="raku" perl6line>use Base::Any;
 
put display :20cols, :fmt('%3d'), (^501).grep( { .&to-base(-16).contains: /<[A..F]>/ } );
Line 1,879 ⟶ 2,352:
cache $list;
$title ~ $list.batch($cols)».fmt($fmt).join: "\n"
}</langsyntaxhighlight>
{{out}}
<pre>306 matching:
Line 1,901 ⟶ 2,374:
Of course, if you are looking for the '''count''' of the hexadecimal numbers up to some threshold that only use "decimal" digits, it is silly and counter-productive to iterate through them and check '''''each''''' when you really only need to check '''''one'''''.
 
<syntaxhighlight lang="raku" perl6line>use Lingua::EN::Numbers;
 
for 500
Line 1,919 ⟶ 2,392:
 
say '';
}</langsyntaxhighlight>
{{out}}
<pre>Quantity of numbers up to 500 that CAN be expressed in hexadecimal without using any alphabetics: 199
Line 1,935 ⟶ 2,408:
=={{header|REXX}}==
REXX automatically uses only uppercase when converting integers to hexadecimal, &nbsp; but the lowercase alphabetic letters were also included for boilerplate code.
<langsyntaxhighlight lang="rexx">/*REXX pgm finds positive integers when shown in hexadecimal require an alphabetic glyph*/
parse arg n cols . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n = 501 /*Not specified? Then use the default.*/
Line 1,959 ⟶ 2,432:
say
say 'Found ' found title
exit 0 /*stick a fork in it, we're all done. */</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 2,001 ⟶ 2,474:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
see "working..." + nl
baseList = ["a","b","c","d","e","f"]
Line 2,028 ⟶ 2,501:
 
see nl + "done..." + nl
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,065 ⟶ 2,538:
done...
</pre>
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
≪ 1 CF
'''WHILE''' DUP '''REPEAT'''
16 MOD LAST / IP SWAP
'''IF''' 9 > '''THEN''' 1 SF '''END'''
'''END''' DROP 1 FS?
≫ ''''A2F?'''' STO
 
≪ { } 1 500 '''FOR''' n '''IF''' n '''A2F? THEN''' n + '''END NEXT''' 440 .2 BEEP ≫ EVAL
{{out}}
<pre>
1: { 10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 }
</pre>
Result coming after 505 seconds on a basic HP-28S, I have added a <code>BEEP</code> instruction at the end of the code. Thus, the program can be used to deliver at the same time 301 numbers needing A to F in base 16 and perfectly cooked ''al dente'' pasta.
===Optimized version===
Faster by 10%:
≪ 1 CF
'''WHILE REPEAT'''
'''IF''' LAST DUP 16 MOD 9 > '''THEN''' NOT 1 SF '''ELSE''' 16 / IP '''END'''
'''END''' 1 FS?
≫ ''''A2F?'''' STO
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">puts (0..500).select{|n| n.digits(16).any?{|d| d >= 10} }.join(" ")</langsyntaxhighlight>
{{out}}
<pre>
Line 2,074 ⟶ 2,570:
=={{header|Sidef}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="ruby">(0..500).grep {|n| n.digits(16).any {|d| d >= 10} }.join(" ").say</langsyntaxhighlight>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
</pre>
 
=={{header|V (Vlang)}}==
{{trans|Go}}
<syntaxhighlight lang="v (vlang)">
const nondecimal = "abcdef"
fn main() {
mut c := 0
for i := i64(0); i <= 500; i++ {
hex := i.hex()
if nondecimal.contains_any(hex) {
print('${i:3d} ')
c++
if c % 15 == 0 {
println('')
}
}
}
println('\n\n$c such numbers found.\n')
}
</syntaxhighlight>
 
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44
45 46 47 58 59 60 61 62 63 74 75 76 77 78 79
90 91 92 93 94 95 106 107 108 109 110 111 122 123 124
125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
250 251 252 253 254 255 266 267 268 269 270 271 282 283 284
285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364
365 366 367 378 379 380 381 382 383 394 395 396 397 398 399
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
 
 
301 such numbers found.
</pre>
 
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<langsyntaxhighlight ecmascriptlang="wren">import "./fmt" for Conv, Fmt
 
var nondecimal = "abcdef"
Line 2,094 ⟶ 2,638:
}
}
System.print("\n\n%(c) such numbers found.")</langsyntaxhighlight>
 
{{out}}
Line 2,125 ⟶ 2,669:
=={{header|XPL0}}==
Borrowed masking concept from C++, which was much more elegant than my first solution.
<langsyntaxhighlight XPL0lang="xpl0">func HasHex(N);
int N;
[while N do
Line 2,144 ⟶ 2,688:
CrLf(0);
IntOut(0, Cnt); Text(0, " such numbers found."); CrLf(0);
]</langsyntaxhighlight>
 
{{out}}
559

edits