Base 16 numbers needing a to f

From Rosetta Code
(Redirected from Base-16 representation)
Base 16 numbers needing a to f 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

Show in decimal notation all positive integers (less than 501) which, when converted to hexadecimal notation, cannot be written without using at least one non-decimal digit ('a' to 'f').

11l

Translation of: Nim
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()
Output:
Found 301 numbers between 0 and 500:

 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 

68000 Assembly

MOVEQ #0,D0      ;clear D0
MOVEM.L D0,D1-D6 ;clear data regs



loop:
MOVE.W D0,D1          ;we'll use D1 as our temp storage.
JSR UnpackNibbles     ;store each nibble in D2,D3,D4,D5 as separate values to ease comparison.

CMP.B #$0A,D2         ;compare to $0A
BCS dontPrintThis     ;if less than, don't print D0 to the screen.
CMP.B #$0A,D3
BCS dontPrintThis     ;repeat the comparison for each nibble.
CMP.B #$0A,D4
BCS dontPrintThis
CMP.B #$0A,D5
BCS dontPrintThis

JSR printD0           ;unimplemented printing routine.


dontPrintThis:        ;loop overhead time
ADDQ.W #1,D0
CMP.W #501,D0
BCS loop

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
forever:
	JMP forever   ;we are done, so trap the program counter to prevent a crash.

;;;;MAIN ENDS HERE


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SUBROUTINES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UnpackNibbles:
;input: D1
MOVEM.W D1,D2-D5
AND.W #$F000,D2
LSR.W #8,D2
LSR.W #4,D2  ;right shift into bottom nibble

AND.W #$0F00,D3
LSR.W #8,D3

AND.W #$00F0,D4
LSR.W #4,D4

AND.W #$000F,D5

RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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
Output:

Screenshot from Atari 8-bit computer

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

Ada

with Ada.Text_Io;

procedure Base_16_Numbers is
   Columns : constant := 24;
   Base    : constant := 16;

   function Has_A_To_F (N : Positive) return Boolean is
      C : Natural := N;
   begin
      while C > 0 loop
         if C mod Base in 16#A# .. 16#F# then
            return True;
         end if;
         C := C / Base;
      end loop;
      return False;
   end Has_A_To_F;

   package Natural_Io is new Ada.Text_Io.Integer_Io (Natural);
   use Ada.Text_Io;
   Count : Natural := 0;
begin
   for N in 1 .. 500 loop
      if Has_A_To_F (N) then
         Count := Count + 1;
         Natural_Io.Put (N, Width => 5);
         if Count mod Columns = 0 then
            New_Line;
         end if;
      end if;
   end loop;
   New_Line (2);
   Put ("Total count: "); Natural_Io.Put (Count, Width => 3); New_Line;
end Base_16_Numbers;
Output:
   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

Total count: 301

ALGOL 68

BEGIN # show numbers that when represented in hex, have at least one a-f digit #
    INT h count := 0;
    FOR i TO 500 DO
        BITS v := BIN i;
        WHILE v /= 16r0 DO
            IF ABS ( v AND 16rf ) < 10
            THEN v := v SHR 4
            ELSE
                v := 16r0;
                print( ( " ", whole( i, -3 ) ) );
                IF ( h count +:= 1 ) MOD 20 = 0 THEN print( ( newline ) ) FI
            FI
        OD
    OD
END
Output:
  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

ALGOL W

% show numbers that when represented in hex, have at least one a-f digit %
begin
    integer hCount;
    hCount := 0;
    for i := 1 until 500 do begin
        integer v;
        v := i;
        while v > 0 do begin
            if ( v rem 16 ) < 10
            then v := v div 16
            else begin
                % found a number that needs a-f in its hex representation %
                v := 0;
                hCOunt := hCOunt + 1;
                writeon( i_w := 3, s_w := 0, " ", i );
                if hCount rem 20 = 0 then write()
            end if_hexDigit_lt_10__
        end while_v_gt_0
    end for_i
end.
Output:
  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

APL

Works with: Dyalog APL
((/⍨)(10.16(¯1))¨)500
Output:
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

AppleScript

Procedural

local output, n, x, ding
set output to {}
repeat with n from 0 to 500
    set x to n
    set ding to (x mod 16 > 9)
    repeat until ((x < 10) or (ding))
        set x to x div 16
        set ding to (x mod 16 > 9)
    end repeat
    if (ding) then set end of output to n
end repeat
return output
Output:
{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}

Functional

Defining a simple predicate, and composing a test with formatted output from a set of generic functions:

-------- INTEGERS NEEDING HEX DIGITS HIGHER THAN 9 -------

-- p :: Int -> Bool
on p(n)
    9 < n and (9 < (n mod 16) or p(n div 16))
end p


--------------------------- TEST -------------------------
on run
    set upperLimit to 500
    set w to length of (upperLimit as string)
    
    set xs to filter(p, enumFromTo(0, upperLimit))
    
    unlines(map(intercalate("  "), ¬
        {{length of xs as string, ¬
            "matches for the predicate:", linefeed}} & ¬
        chunksOf(6, map(justifyRight(w, space), xs))))
end run


------------------------- GENERIC ------------------------

-- chunksOf :: Int -> [a] -> [[a]]
on chunksOf(k, xs)
    script
        on go(ys)
            set ab to splitAt(k, ys)
            set a to item 1 of ab
            if {}  a then
                {a} & go(item 2 of ab)
            else
                a
            end if
        end go
    end script
    result's go(xs)
end chunksOf


-- enumFromTo :: Int -> Int -> [Int]
on enumFromTo(m, n)
    if m  n then
        set lst to {}
        repeat with i from m to n
            set end of lst to i
        end repeat
        lst
    else
        {}
    end if
end enumFromTo


-- filter :: (a -> Bool) -> [a] -> [a]
on filter(p, xs)
    tell mReturn(p)
        set lst to {}
        set lng to length of xs
        repeat with i from 1 to lng
            set v to item i of xs
            if |λ|(v, i, xs) then set end of lst to v
        end repeat
        if {text, string} contains class of xs then
            lst as text
        else
            lst
        end if
    end tell
end filter


-- intercalate :: String -> [String] -> String
on intercalate(delim)
    script
        on |λ|(xs)
            set {dlm, my text item delimiters} to ¬
                {my text item delimiters, delim}
            set s to xs as text
            set my text item delimiters to dlm
            s
        end |λ|
    end script
end intercalate


-- justifyRight :: Int -> Char -> String -> String
on justifyRight(n, cFiller)
    script
        on |λ|(x)
            set s to x as string
            if n > length of s then
                text -n thru -1 of ((replicate(n, cFiller) as text) & s)
            else
                s
            end if
        end |λ|
    end script
end justifyRight


-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
    -- 2nd class handler function lifted into 1st class script wrapper. 
    if script is class of f then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn


-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
    -- The list obtained by applying f
    -- to each element of xs.
    tell mReturn(f)
        set lng to length of xs
        set lst to {}
        repeat with i from 1 to lng
            set end of lst to |λ|(item i of xs, i, xs)
        end repeat
        return lst
    end tell
end map


-- Egyptian multiplication - progressively doubling a list, appending
-- stages of doubling to an accumulator where needed for binary 
-- assembly of a target length
-- replicate :: Int -> String -> String
on replicate(n, s)
    -- Egyptian multiplication - progressively doubling a list, 
    -- appending stages of doubling to an accumulator where needed 
    -- for binary assembly of a target length
    script p
        on |λ|({n})
            n  1
        end |λ|
    end script
    
    script f
        on |λ|({n, dbl, out})
            if (n mod 2) > 0 then
                set d to out & dbl
            else
                set d to out
            end if
            {n div 2, dbl & dbl, d}
        end |λ|
    end script
    
    set xs to |until|(p, f, {n, s, ""})
    item 2 of xs & item 3 of xs
end replicate


-- splitAt :: Int -> [a] -> ([a], [a])
on splitAt(n, xs)
    if n > 0 and n < length of xs then
        if class of xs is text then
            {items 1 thru n of xs as text, ¬
                items (n + 1) thru -1 of xs as text}
        else
            {items 1 thru n of xs, items (n + 1) thru -1 of xs}
        end if
    else
        if n < 1 then
            {{}, xs}
        else
            {xs, {}}
        end if
    end if
end splitAt


-- unlines :: [String] -> String
on unlines(xs)
    -- A single string formed by the intercalation
    -- of a list of strings with the newline character.
    set {dlm, my text item delimiters} to ¬
        {my text item delimiters, linefeed}
    set s to xs as text
    set my text item delimiters to dlm
    s
end unlines


-- until :: (a -> Bool) -> (a -> a) -> a -> a
on |until|(p, f, x)
    set v to x
    set mp to mReturn(p)
    set mf to mReturn(f)
    repeat until mp's |λ|(v)
        set v to mf's |λ|(v)
    end repeat
    v
end |until|
Output:
301  matches for the predicate:  

 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

Arturo

needsAF?: function [x][
    hex: as.hex x
    loop `a`..`f` 'c [
        if contains? hex c ->
            return true
    ]
    return false
]

print select 0..500 => needsAF?
Output:
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

AWK

# syntax: GAWK -f BASE-16_REPRESENTATION.AWK
BEGIN {
    start = 1
    stop = 500
    for (i=start; i<=stop; i++) {
      if (sprintf("%X",i) ~ /[A-F]/) {
        printf("%4d%1s",i,++count%20?"":"\n")
      }
    }
    printf("\nIntegers when displayed in hex require an A-F, %d-%d: %d\n",start,stop,count)
    exit(0)
}
Output:
  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
Integers when displayed in hex require an A-F, 1-500: 301

BASIC

BASIC256

function needs_af (n)
	while n > 0
		if (n % 16) > 9 then return true
		n = n \ 16
	end while
	return false
end function

for i = 1 to 500
	if needs_af(i) then print i; " ";
next i
end

Chipmunk Basic

The GW-BASIC solution works without any changes.

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
Output:

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

Gambas

Translation of: FreeBASIC
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

GW-BASIC

Works with: BASICA
Works with: Chipmunk Basic
Works with: MSX_BASIC
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
Output:
 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           152
 153           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
 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
 408           409           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

MSX Basic

The GW-BASIC solution works without any changes.

QuickBASIC

Translation of: Modula-2
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
Output:
  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.

Run BASIC

Works with: Just BASIC
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
Output:
Same as FreeBASIC entry.

True BASIC

Translation of: QuickBASIC
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
Output:
Same as QuickBASIC entry.

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

BCPL

get "libhdr"

let nondec(x) = 
    x = 0 -> false,
    #XA <= (x & #XF) <= #XF -> true,
    nondec(x >> 4)
    
let start() be
$(  let c = 0
    for n=1 to 500
        if nondec(n) 
        $(  writed(n,4)
            c := c + 1
            if c rem 20=0 then wrch('*N')
        $)
    wrch('*N')
$)
Output:
  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

BQN

437  / 9 < 16 ÷˜•_while_(  9  |)¨ 501
Output:
┌─
╵  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
                              ┘

C++

#include <iomanip>
#include <iostream>

// Returns true if the hexadecimal representation of n contains at least one
// non-decimal digit.
bool nondecimal(unsigned int n) {
    for (; n > 0; n >>= 4) {
        if ((n & 0xF) > 9)
            return true;
    }
    return false;
}

int main() {
    unsigned int count = 0;
    for (unsigned int n = 0; n < 501; ++n) {
        if (nondecimal(n)) {
            ++count;
            std::cout << std::setw(3) << n << (count % 15 == 0 ? '\n' : ' ');
        }
    }
    std::cout << "\n\n" << count << " such numbers found.\n";
}
Output:
 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.

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
Output:
  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.

COBOL

        IDENTIFICATION DIVISION.
        PROGRAM-ID. BASE-16.
        
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 VARIABLES        COMP.
           02 STRP          PIC 99 VALUE 1.
           02 N             PIC 999.
           02 NTEMP         PIC 999.
           02 N16           PIC 999.
           02 NMOD16        PIC 99.
           02 BASE16-FLAG   PIC 9.
              88 BASE16     VALUE 1.
           02 AMOUNT        PIC 999 VALUE 0.
           
        01 OUTPUT-FORMAT.
           02 LINESTR       PIC X(72).
           02 OUTN          PIC BZZ9.
           
        PROCEDURE DIVISION.
        BEGIN.
            PERFORM NONDEC VARYING N FROM 1 BY 1 
                UNTIL N IS GREATER THAN 500.
            PERFORM DISPLAY-LINE.
            DISPLAY ' '.
            MOVE AMOUNT TO OUTN.
            DISPLAY OUTN ' numbers found.'
            STOP RUN.
        
        NONDEC.
            MOVE N TO NTEMP.
            PERFORM IS-NONDEC.
            IF BASE16
                MOVE N TO OUTN
                STRING OUTN DELIMITED BY SIZE INTO LINESTR
                    WITH POINTER STRP
                ADD 1 TO AMOUNT
                IF STRP IS EQUAL TO 73 PERFORM DISPLAY-LINE.
                        
        DISPLAY-LINE.
            IF STRP IS NOT EQUAL TO 1 DISPLAY LINESTR.
            MOVE 1 TO STRP.
            MOVE ' ' TO LINESTR.
            
        IS-NONDEC.
            IF NTEMP IS EQUAL TO ZERO
                MOVE 0 TO BASE16-FLAG
            ELSE
                DIVIDE NTEMP BY 16 GIVING N16
                COMPUTE NMOD16 = NTEMP - N16 * 16
                IF NMOD16 IS NOT LESS THAN 10
                    MOVE 1 TO BASE16-FLAG
                ELSE
                    MOVE N16 TO NTEMP
                    GO TO IS-NONDEC.
Output:
  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.

Cowgol

include "cowgol.coh";

sub nondecimal(n: uint16): (r: uint8) is
    r := 0;
    while n != 0 loop
        if n & 15 >= 10 then 
            r := 1;
            return;
        else
            n := n >> 4;
        end if;
    end loop;
end sub;

var i: uint16 := 0;
var c: uint8 := 0;
while i <= 500 loop
    if nondecimal(i) != 0 then
        print_i16(i);
        if c<9 then
            print_char('\t');
            c := c + 1;
        else
            print_nl();
            c := 0;
        end if;
    end if;
    i := i + 1;
end loop;
print_nl();
Output:
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

Delphi

Works with: Delphi version 6.0

An example of using Delphi-style operations using set operators to find hex nibbles A..F

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;
Output:
  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


F#

// 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 ""
Output:
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

Factor

The non-decimal? word is a translation of C++'s nondecimal function. Having multiple exit points in a word is not very efficient (yet?) in Factor, so I've tweaked it to have one exit point at the end.

Works with: Factor version 0.99 2021-02-05
USING: combinators formatting grouping io kernel lists
lists.lazy math prettyprint sequences ;

! Returns t if the hexadecimal representation of n contains a
! non-decimal digit.
: non-decimal? ( n -- ? )
    {
        { [ dup zero? ] [ drop f ] }
        { [ dup 0xF bitand 9 > ] [ drop t ] }
        [ -4 shift non-decimal? ]
    } cond ;

1 lfrom [ non-decimal? ] lfilter [ 501 < ] lwhile
list>array dup 15 group [ [ "%3d " printf ] each nl ] each nl
length pprint " such numbers found." print
Output:
 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.

The above solution uses lazy computation and tail recursion. Here's an eager solution, but it allocates a lot of intermediate sequences.

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
Output:

Same numbers as above, but on a single line.

FOCAL

01.10 S C=0
01.20 F N=1,500;D 2
01.30 T !
01.40 Q

02.10 S X=N
02.20 S Y=FITR(X/16)
02.30 S Z=X-Y*16
02.40 I (Z-10)2.5,2.7,2.7
02.50 S X=Y
02.60 I (X),2.99,2.2
02.70 T %3,N
02.80 S C=C+1
02.90 I (C-10)2.99;T !;S C=0
02.99 R
Output:
=  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

Forth

Works with: Gforth
\ Returns true if the hexadecimal representation of n contains at least one
\ non-decimal digit.
: non-decimal ( u -- ? )
  begin
    dup 0 >
  while
    dup 15 and 9 > if
      drop true exit
    then
    4 rshift
  repeat
  drop false ;

: main
  0
  501 0 do
    i non-decimal if
      1+
      i 3 .r
      dup 15 mod 0= if cr else space then
    then
  loop
  cr cr . ." such numbers found." cr ;

main
bye
Output:
 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.

Frink

select[1 to 500, {|n| base16[n] =~ %r/[a-f]/i}]
Output:
[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]

Go

Translation of: Wren
package main

import (
    "fmt"
    "strconv"
    "strings"
)

func main() {
    const nondecimal = "abcdef"
    c := 0
    for i := int64(0); i <= 500; i++ {
        hex := strconv.FormatInt(i, 16)
        if strings.ContainsAny(nondecimal, hex) {
            fmt.Printf("%3d ", i)
            c++
            if c%15 == 0 {
                fmt.Println()
            }
        }
    }
    fmt.Printf("\n\n%d such numbers found.\n", c)
}
Output:
 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.

Haskell

import Data.List (intercalate, transpose)
import Data.List.Split (chunksOf)
import Text.Printf (printf)

------- ANY DIGIT ABOVE 9 REQUIRED IN HEXADECIMAL ? ------

p :: Int -> Bool
p n =
  9 < n
    && ( 9 < rem n 16
           || p (quot n 16)
       )

--------------------------- TEST -------------------------
main :: IO ()
main =
  let upperLimit = 500
      xs = [show x | x <- [0 .. upperLimit], p x]
   in mapM_
        putStrLn
        [ show (length xs)
            <> " matches up to "
            <> show upperLimit
            <> ":\n",
          table justifyRight " " $ chunksOf 15 xs
        ]

------------------------- DISPLAY ------------------------

table ::
  (Int -> Char -> String -> String) ->
  String ->
  [[String]] ->
  String
table alignment gap rows =
  unlines $
    fmap
      ( intercalate gap
          . zipWith (`alignment` ' ') colWidths
      )
      rows
  where
    colWidths = maximum . fmap length <$> transpose rows

justifyRight :: Int -> Char -> String -> String
justifyRight n c = (drop . length) <*> (replicate n c <>)
Output:
301 matches up to 500:

 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

J

needsAtoF=. (9 +./@:< 16&#.inv)"0

_16 echo\ I. needsAtoF i. 501
Output:
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

JavaScript

(() => {
    "use strict";

    // --- ANY ALPHA DIGITS REQUIRED IN HEXADECIMAL ? ----

    // p :: Int -> Bool
    const p = n =>
        // True if a hexadecimal representation of the
        // integer n requires any digits above 9.
        9 < n && (
            9 < n % 16 || p(
                Math.trunc(n / 16)
            )
        );


    // ---------------------- TEST -----------------------
    // main :: IO ()
    const main = () => {
        const
            upperLimit = 500,
            xs = enumFromTo(0)(upperLimit)
            .flatMap(
                x => p(x) ? [
                    `${x}`
                ] : []
            );

        return [
            `${xs.length} matches up to ${upperLimit}:\n`,
            table("  ")(justifyRight)(
                chunksOf(6)(xs)
            )
        ].join("\n");
    };


    // --------------------- DISPLAY ---------------------

    // table :: String ->
    // (Int -> Char -> String -> String) ->
    // [[String]] -> String
    const table = gap =>
        // A tabulation of rows of string values,
        // with a specified gap between columns,
        // and choice of cell alignment function
        // (justifyLeft | center | justifyRight)
        alignment => rows => {
            const
                colWidths = transpose(rows).map(
                    row => maximum(row.map(x => x.length))
                );

            return rows.map(
                compose(
                    intercalate(gap),
                    zipWith(
                        flip(alignment)(" ")
                    )(colWidths)
                )
            ).join("\n");
        };


    // --------------------- GENERIC ---------------------

    // chunksOf :: Int -> [a] -> [[a]]
    const chunksOf = n => {
        // xs split into sublists of length n.
        // The last sublist will be short if n
        // does not evenly divide the length of xs .
        const go = xs => {
            const chunk = xs.slice(0, n);

            return 0 < chunk.length ? (
                [chunk].concat(
                    go(xs.slice(n))
                )
            ) : [];
        };

        return go;
    };


    // compose (<<<) :: (b -> c) -> (a -> b) -> a -> c
    const compose = (...fs) =>
        // A function defined by the right-to-left
        // composition of all the functions in fs.
        fs.reduce(
            (f, g) => x => f(g(x)),
            x => x
        );


    // enumFromTo :: Int -> Int -> [Int]
    const enumFromTo = m =>
        n => Array.from({
            length: 1 + n - m
        }, (_, i) => m + i);


    // flip :: (a -> b -> c) -> b -> a -> c
    const flip = op =>
        // The binary function op with
        // its arguments reversed.
        1 < op.length ? (
            (a, b) => op(b, a)
        ) : (x => y => op(y)(x));


    // intercalateS :: String -> [String] -> String
    const intercalate = s =>
        // The concatenation of xs
        // interspersed with copies of s.
        xs => xs.join(s);


    // justifyRight :: Int -> Char -> String -> String
    const justifyRight = n =>
        // The string s, preceded by enough padding (with
        // the character c) to reach the string length n.
        c => s => Boolean(s) ? (
            s.padStart(n, c)
        ) : "";


    // maximum :: Ord a => [a] -> a
    const maximum = xs => (
        // The largest value in a non-empty list.
        ys => 0 < ys.length ? (
            ys.slice(1).reduce(
                (a, y) => y > a ? (
                    y
                ) : a, ys[0]
            )
        ) : undefined
    )(xs);


    // transpose :: [[a]] -> [[a]]
    const transpose = rows => {
        // If any rows are shorter than those that follow,
        // their elements are skipped:
        // > transpose [[10,11],[20],[],[30,31,32]]
        //             == [[10,20,30],[11,31],[32]]
        const go = xss =>
            0 < xss.length ? (() => {
                const
                    h = xss[0],
                    t = xss.slice(1);

                return 0 < h.length ? [
                    [h[0]].concat(t.reduce(
                        (a, xs) => a.concat(
                            0 < xs.length ? (
                                [xs[0]]
                            ) : []
                        ),
                        []
                    ))
                ].concat(go([h.slice(1)].concat(
                    t.map(xs => xs.slice(1))
                ))) : go(t);
            })() : [];

        return go(rows);
    };


    // zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
    const zipWith = f =>
        // A list constructed by zipping with a
        // custom function, rather than with the
        // default tuple constructor.
        xs => ys => xs.map(
            (x, i) => f(x)(ys[i])
        ).slice(
            0, Math.min(xs.length, ys.length)
        );

    // MAIN ---
    return main();
})();
Output:
301 matches up to 500:

 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

jq

Works with: jq

Works with gojq, the Go implementation of jq

# decimal number to hex string using lower-case letters
def hex:
  def stream:
    recurse(if . >= 16 then ./16|floor else empty end) | . % 16 ;
  [stream] | reverse 
  |  map(if . < 10 then 48 + . else . + 87 end) | implode
  end;


# For pretty-printing
def nwise($n):
  def n: if length <= $n then . else .[0:$n] , (.[$n:] | n) end;
  n;

def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;

def task:
  ["a","b","c","d","e","f"] as $letters
  | [ range(1;501)
     | (hex | explode | map([.]|implode)) as $hex
     | select( any($hex[]; IN( $letters[] )))]
  | nwise(10) | map(lpad(4)) | join("")
  ;
task
Output:
  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

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))
Output:
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

Mathematica/Wolfram Language

Select[Range[500], AnyTrue[IntegerDigits[#, 16], GreaterEqualThan[10]] &]
Output:
{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}

Modula-2

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.
Output:
  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.

Nim

import strutils, sugar

let list = collect(newSeq):
             for n in 0..500:
               if not n.toHex.allCharsInSet(Digits): n

echo "Found ", list.len, " numbers between 0 and 500:\n"
for i, n in list:
  stdout.write ($n).align(3), if (i + 1) mod 19 == 0: '\n' else: ' '
echo()
Output:
Found 301 numbers between 0 and 500:

 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 

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
Output:
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

Perl

#!/usr/bin/perl

use strict; # https://rosettacode.org/wiki/Base-16_representation
use warnings;

print join( ' ', grep sprintf("%x", $_) =~ tr/a-z//, 1 .. 500 ) =~
  s/.{71}\K /\n/gr, "\n";
Output:
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


Phix

with javascript_semantics
function above9(integer n) return max(sprintf("%x",n))>'9' end function
printf(1,"%s\n",{join(shorten(apply(filter(tagset(500),above9),sprint),"found",10))})
Output:
10 11 12 13 14 15 26 27 28 29 ... 491 492 493 494 495 496 497 498 499 500  (301 found)
Translation of: Raku – someone got their clever hat on there
with javascript_semantics
requires("1.0.0")
include mpfr.e
sequence tests = {"500","1e8","1e25","1e35"}
constant fmt = "%47s %40s %47s\n"
printf(1,fmt,{"threshold","can","cannot"})
for t=1 to length(tests) do
    mpz threshold = mpz_init(tests[t])
    string thresh = mpz_get_str(threshold,10,true)
    object limit = mpz_get_str(threshold,16)
    for i=1 to length(limit) do
        if limit[i]>'9' then limit[i..$] = '9' exit end if
    end for
    limit = mpz_init(limit)
    mpz_sub(threshold,threshold,limit)
    string can = mpz_get_str(limit,10,true),
        cannot = mpz_get_str(threshold,10,true)
    printf(1,fmt,{thresh,can,cannot})
end for
Output:
                                      threshold                                      can                                          cannot
                                            500                                      199                                             301
                                    100,000,000                                5,999,999                                      94,000,001
             10,000,000,000,000,000,000,000,000              845,951,614,014,849,999,999               9,999,154,048,385,985,150,000,001
100,000,000,000,000,000,000,000,000,000,000,000  134,261,729,999,999,999,999,999,999,999  99,999,865,738,270,000,000,000,000,000,000,001

Explanation: Consider a limit of 8191, or #1FFF, clearly 1999 (decimal) can be expressed without A..F, the rest with one or more.
Slightly less obvious, a limit of 8192 or #2000, clearly 2000 (decimal) can be expressed without A..F, the rest with one or more.
In other words all those "decimal-looking" numbers will occur in order, and no other "decimal" numbers, with others that need hex chars interspersed.

PL/M

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;
   /* PRINTS A BYTE AS A CHARACTER */
   PRINT$CHAR: PROCEDURE( C ); DECLARE C BYTE; CALL BDOS( 2, C ); END;
   /* PRINTS A $ TERMINATED STRING */
   PRINT$STRING: PROCEDURE( S ); DECLARE S ADDRESS; CALL BDOS( 9, S ); END;

   /* PRINTS A NUMBER IN THE MINIMUN FIELD WIDTH */
   PRINT$NUMBER: PROCEDURE( N );
      DECLARE N ADDRESS;
      DECLARE V ADDRESS, N$STR ( 6 )BYTE, W BYTE;
      V = N;
      W = LAST( N$STR );
      N$STR( W ) = '$';
      N$STR( W := W - 1 ) = '0' + ( V MOD 10 );
      DO WHILE( ( V := V / 10 ) > 0 );
         N$STR( W := W - 1 ) = '0' + ( V MOD 10 );
      END;
      CALL PRINT$STRING( .N$STR( W ) );
   END PRINT$NUMBER;

   DECLARE ( H$COUNT, I, V ) ADDRESS;
   H$COUNT = 0;
   DO I = 1 TO 500;
      V = I;
      DO WHILE( V > 0 );
         IF ( V AND 0FH ) < 0AH
         THEN V = SHR( V, 4 );
         ELSE DO;
            V = 0;
            CALL PRINT$CHAR( ' ' );
            IF I <  10 THEN CALL PRINT$CHAR( ' ' );
            IF I < 100 THEN CALL PRINT$CHAR( ' ' );
            CALL PRINT$NUMBER( I );
            H$COUNT = H$COUNT + 1;
            IF H$COUNT >= 20 THEN DO;
                CALL PRINT$STRING( .( 0DH, 0AH, '$' ) );
                H$COUNT = 0;
            END;
         END;
      END;
   END;
EOF
Output:
  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

Python

'''Integers needing any alpha digits in hex'''


# p :: Int -> Bool
def p(n):
    '''True if n requires any digits above 9
       when expressed as a hexadecimal.
    '''
    return 9 < n and (9 < n % 16 or p(n // 16))


# ------------------------- TEST -------------------------
# main :: IO ()
def main():
    '''Matches for the predicate p in the range [0..500]'''
    xs = [
        str(n) for n in range(1, 1 + 500)
        if p(n)
    ]
    print(f'{len(xs)} matches for the predicate:\n')
    print(
        table(6)(xs)
    )


# ----------------------- GENERIC ------------------------

# chunksOf :: Int -> [a] -> [[a]]
def chunksOf(n):
    '''A series of lists of length n, subdividing the
       contents of xs. Where the length of xs is not evenly
       divisible, the final list will be shorter than n.
    '''
    def go(xs):
        return (
            xs[i:n + i] for i in range(0, len(xs), n)
        ) if 0 < n else None
    return go


# table :: Int -> [String] -> String
def table(n):
    '''A list of strings formatted as
       right-justified rows of n columns.
    '''
    def go(xs):
        w = len(xs[-1])
        return '\n'.join(
            ' '.join(row) for row in chunksOf(n)([
                s.rjust(w, ' ') for s in xs
            ])
        )
    return go


# MAIN ---
if __name__ == '__main__':
    main()
Output:
301 matches for the predicate:

 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

Quackery

  [ false swap
      [ dup 0 != while
        16 /mod
        9 > iff
          [ dip not ]
          done
        again ]
    drop ]             is haslet ( n --> b )

  []
  501 times
    [ i^ haslet if
        [ i^ number$
          nested join ] ]
  60 wrap$
Output:
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

Raku

Yet another poorly specced, poorly named, trivial task.

How many integers in base 16 cannot be written without using a hexadecimal digit? All of them. Or none of them.

Base 16 is not hexadecimal. Hexadecimal is an implementation of base 16.

use Base::Any;
set-digits <⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳ ㉑ ㉒ ㉓ ㉔ ㉕>;
say (7**35).&to-base(16);

# ⑭㉒⑱⑩⑰⑰⑳⑮⑱⑳⑩⑳⑱㉒㉑⑰㉒⑫⑭⑲⑯⑩㉔⑮⑰

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.

But wait a minute; is 2 a hexadecimal digit? Why yes, yes it is. So none of them can be written in hexadecimal without using a hexadecimal digit.


Bah. Show which when written in base 16, contain a digit glyph with a value greater than 9:

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"
}
Output:
301 matching:
 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

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.

use Base::Any;

put display :20cols, :fmt('%3d'), (^501).grep( { .&to-base(-16).contains: /<[A..F]>/ } );

sub display ($list, :$cols = 10, :$fmt = '%6d', :$title = "{+$list} matching:\n" )   {
    cache $list;
    $title ~ $list.batch($cols)».fmt($fmt).join: "\n"
}
Output:
306 matching:
 10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29
 30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49
 50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69
 70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89
 90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
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 266 267 268 269
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 426 427 428 429
430 431 442 443 444 445 446 447 458 459 460 461 462 463 474 475 476 477 478 479
490 491 492 493 494 495

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.

use Lingua::EN::Numbers;

for 500
   ,10**8
   ,10**25
   ,10**35
   -> $threshold {
    my $limit = $threshold.base(16);
    my $i  = $limit.index: ['A'..'F'];
    quietly $limit = $limit.substr(0, $i) ~ ('9' x ($limit.chars - $i)) if $i.Str;

    for '  CAN  ', $limit,
        'CAN NOT', $threshold - $limit {
        printf( "Quantity of numbers up to %s that %s be expressed in hexadecimal without using any alphabetics: %*s\n",
         comma($threshold), $^a, comma($threshold).chars, comma($^c) )
    }

    say '';
}
Output:
Quantity of numbers up to 500 that   CAN   be expressed in hexadecimal without using any alphabetics: 199
Quantity of numbers up to 500 that CAN NOT be expressed in hexadecimal without using any alphabetics: 301

Quantity of numbers up to 100,000,000 that   CAN   be expressed in hexadecimal without using any alphabetics:   5,999,999
Quantity of numbers up to 100,000,000 that CAN NOT be expressed in hexadecimal without using any alphabetics:  94,000,001

Quantity of numbers up to 10,000,000,000,000,000,000,000,000 that   CAN   be expressed in hexadecimal without using any alphabetics:        845,951,614,014,849,999,999
Quantity of numbers up to 10,000,000,000,000,000,000,000,000 that CAN NOT be expressed in hexadecimal without using any alphabetics:  9,999,154,048,385,985,150,000,001

Quantity of numbers up to 100,000,000,000,000,000,000,000,000,000,000,000 that   CAN   be expressed in hexadecimal without using any alphabetics:         134,261,729,999,999,999,999,999,999,999
Quantity of numbers up to 100,000,000,000,000,000,000,000,000,000,000,000 that CAN NOT be expressed in hexadecimal without using any alphabetics:  99,999,865,738,270,000,000,000,000,000,000,001

REXX

REXX automatically uses only uppercase when converting integers to hexadecimal,   but the lowercase alphabetic letters were also included for boilerplate code.

/*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.*/
if cols=='' | cols==","  then cols=  10          /* "      "         "   "   "     "    */
w= 10                                            /*width of a number in any column.     */
title= ' positive integers when displayed in hexadecimal that require an alphabetic'  ,
       "glyph,  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= 'abcdefABCDEF';       idx= 1  /*initialize # of high hexadecimal nums*/
$=                                               /*list of high hexadecimal #'s (so far)*/
    do j=1  for n-1                              /*search for high hexadecimal numbers. */
    if verify(y, d2x(j), 'M')==0  then iterate   /*No alphabetical characters? Then skip*/    /* ◄■■■■■■■■ the filter. */
    found= found + 1                             /*bump number of high hexadecimal #'s. */
    $= $  right(j, w)                            /*add a high hexadecimal 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. */
output   when using the default inputs:
 index │       positive integers when displayed in hexadecimal that require an alphabetic glyph,  where  N <  501
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │         10         11         12         13         14         15         26         27         28         29
  11   │         30         31         42         43         44         45         46         47         58         59
  21   │         60         61         62         63         74         75         76         77         78         79
  31   │         90         91         92         93         94         95        106        107        108        109
  41   │        110        111        122        123        124        125        126        127        138        139
  51   │        140        141        142        143        154        155        156        157        158        159
  61   │        160        161        162        163        164        165        166        167        168        169
  71   │        170        171        172        173        174        175        176        177        178        179
  81   │        180        181        182        183        184        185        186        187        188        189
  91   │        190        191        192        193        194        195        196        197        198        199
  101  │        200        201        202        203        204        205        206        207        208        209
  111  │        210        211        212        213        214        215        216        217        218        219
  121  │        220        221        222        223        224        225        226        227        228        229
  131  │        230        231        232        233        234        235        236        237        238        239
  141  │        240        241        242        243        244        245        246        247        248        249
  151  │        250        251        252        253        254        255        266        267        268        269
  161  │        270        271        282        283        284        285        286        287        298        299
  171  │        300        301        302        303        314        315        316        317        318        319
  181  │        330        331        332        333        334        335        346        347        348        349
  191  │        350        351        362        363        364        365        366        367        378        379
  201  │        380        381        382        383        394        395        396        397        398        399
  211  │        410        411        412        413        414        415        416        417        418        419
  221  │        420        421        422        423        424        425        426        427        428        429
  231  │        430        431        432        433        434        435        436        437        438        439
  241  │        440        441        442        443        444        445        446        447        448        449
  251  │        450        451        452        453        454        455        456        457        458        459
  261  │        460        461        462        463        464        465        466        467        468        469
  271  │        470        471        472        473        474        475        476        477        478        479
  281  │        480        481        482        483        484        485        486        487        488        489
  291  │        490        491        492        493        494        495        496        497        498        499
  301  │        500
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────

Found  301  positive integers when displayed in hexadecimal that require an alphabetic glyph,  where  N <  501

Ring

see "working..." + nl
baseList = ["a","b","c","d","e","f"]
row = 1
limit = 500

for n = 1 to limit
    num = 0
    flag = 1
    hex = hex(n)
    lenHex = len(hex)
    for m = 1 to lenHex        
        ind = find(baseList,hex[m])
        if ind < 1
           num = num + 1
        ok
    next
    if num != lenHex
       row = row + 1
       see "" + n + " "
       if row%10 = 0
          see nl
       ok
    ok
next

see nl + "done..." + nl
Output:
working...
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 
done...

RPL

Works with: Halcyon Calc version 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
Output:
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 }

Result coming after 505 seconds on a basic HP-28S, I have added a BEEP 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

Ruby

puts (0..500).select{|n| n.digits(16).any?{|d| d >= 10} }.join(" ")
Output:
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

Sidef

Translation of: Ruby
(0..500).grep {|n| n.digits(16).any {|d| d >= 10} }.join(" ").say
Output:
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

V (Vlang)

Translation of: Go
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')
}
Output:
 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.

Wren

Library: Wren-fmt
import "./fmt" for Conv, Fmt

var nondecimal = "abcdef"
var c = 0
for (i in 0..500) {
    var hex = Conv.hex(i)
    if (hex.any { |c| nondecimal.contains(c) }) {
        Fmt.write("$3s ", i)
        c = c + 1
        if (c % 15 == 0) System.print()
    }
}
System.print("\n\n%(c) such numbers found.")
Output:
 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.

XPL0

Borrowed masking concept from C++, which was much more elegant than my first solution.

func HasHex(N);
int  N;
[while N do
     [if (N&$F) > 9 then return true;  N:= N>>4];
return false;
];

int N, Cnt;
[Cnt:= 0;
for N:= 1 to 500 do
    [if HasHex(N) then
        [if N<100 then ChOut(0, ^ );
        IntOut(0, N);
        Cnt:= Cnt+1;
        if rem(Cnt/20) = 0 then CrLf(0) else ChOut(0, ^ );
        ];
    ];
CrLf(0);
IntOut(0, Cnt);  Text(0, " such numbers found.");  CrLf(0);
]
Output:
 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.