Base-16 representation: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎{{header|REXX}}: changed output title, simplified code.)
(moved page)
 
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
#REDIRECT [[Base_16_numbers_needing_a_to_f]]
{{Draft task}}

;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').
<br><br>

=={{header|ALGOL 68}}==
<lang algol68>BEGIN # show numbers that when represented in hex, have at least one a-f digit #
INT h count := 0;
FOR i TO 500 DO
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</lang>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
</pre>

=={{header|ALGOL W}}==
<lang algolw>% 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.</lang>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
</pre>

=={{header|APL}}==
{{works with|Dyalog APL}}
<lang APL>(⊢(/⍨)(10∨.≤16(⊥⍣¯1)⊢)¨)⍳500</lang>
{{out}}
<pre>10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63
74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122
123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300
301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346
347 348 349 350 351 362 363 364 365 366 367 378 379 380 381 382
383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
499 500</pre>
=={{header|AWK}}==
<lang 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)
}
</lang>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
Integers when displayed in hex require an A-F, 1-500: 301
</pre>

=={{header|BASIC}}==
<lang 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</lang>
{{out}}
<pre style='height:50ex'> 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</pre>

=={{header|BCPL}}==
<lang 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')
$)</lang>
{{out}}
<pre> 10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500</pre>

=={{header|C++}}==
<lang cpp>#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";
}</lang>

{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44
45 46 47 58 59 60 61 62 63 74 75 76 77 78 79
90 91 92 93 94 95 106 107 108 109 110 111 122 123 124
125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
250 251 252 253 254 255 266 267 268 269 270 271 282 283 284
285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364
365 366 367 378 379 380 381 382 383 394 395 396 397 398 399
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500

301 such numbers found.
</pre>

=={{header|Cowgol}}==
<lang 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();</lang>
{{out}}
<pre>10 11 12 13 14 15 26 27 28 29
30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79
90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139
140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169
170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189
190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209
210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229
230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249
250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299
300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349
350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399
410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429
430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449
450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469
470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489
490 491 492 493 494 495 496 497 498 499
500</pre>

=={{header|F_Sharp|F#}}==
<lang fsharp>
// Base 16 representation: Nigel Galloway. June 3rd., 2021
let rec fN g=match g%16,g/16 with (n,0)->9<n |(n,g) when n<10->fN g |_->true
seq{1..500}|>Seq.filter fN|>Seq.iter(printf "%d "); printfn ""
</lang>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
</pre>

=={{header|Factor}}==
The <code>non-decimal?</code> word is a translation of C++'s <code>nondecimal</code> 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|0.99 2021-02-05}}
<lang factor>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</lang>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44
45 46 47 58 59 60 61 62 63 74 75 76 77 78 79
90 91 92 93 94 95 106 107 108 109 110 111 122 123 124
125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
250 251 252 253 254 255 266 267 268 269 270 271 282 283 284
285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364
365 366 367 378 379 380 381 382 383 394 395 396 397 398 399
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500

301 such numbers found.
</pre>

=={{header|FOCAL}}==
<lang 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</lang>
{{out}}
<pre>= 10= 11= 12= 13= 14= 15= 26= 27= 28= 29
= 30= 31= 42= 43= 44= 45= 46= 47= 58= 59
= 60= 61= 62= 63= 74= 75= 76= 77= 78= 79
= 90= 91= 92= 93= 94= 95= 106= 107= 108= 109
= 110= 111= 122= 123= 124= 125= 126= 127= 138= 139
= 140= 141= 142= 143= 154= 155= 156= 157= 158= 159
= 160= 161= 162= 163= 164= 165= 166= 167= 168= 169
= 170= 171= 172= 173= 174= 175= 176= 177= 178= 179
= 180= 181= 182= 183= 184= 185= 186= 187= 188= 189
= 190= 191= 192= 193= 194= 195= 196= 197= 198= 199
= 200= 201= 202= 203= 204= 205= 206= 207= 208= 209
= 210= 211= 212= 213= 214= 215= 216= 217= 218= 219
= 220= 221= 222= 223= 224= 225= 226= 227= 228= 229
= 230= 231= 232= 233= 234= 235= 236= 237= 238= 239
= 240= 241= 242= 243= 244= 245= 246= 247= 248= 249
= 250= 251= 252= 253= 254= 255= 266= 267= 268= 269
= 270= 271= 282= 283= 284= 285= 286= 287= 298= 299
= 300= 301= 302= 303= 314= 315= 316= 317= 318= 319
= 330= 331= 332= 333= 334= 335= 346= 347= 348= 349
= 350= 351= 362= 363= 364= 365= 366= 367= 378= 379
= 380= 381= 382= 383= 394= 395= 396= 397= 398= 399
= 410= 411= 412= 413= 414= 415= 416= 417= 418= 419
= 420= 421= 422= 423= 424= 425= 426= 427= 428= 429
= 430= 431= 432= 433= 434= 435= 436= 437= 438= 439
= 440= 441= 442= 443= 444= 445= 446= 447= 448= 449
= 450= 451= 452= 453= 454= 455= 456= 457= 458= 459
= 460= 461= 462= 463= 464= 465= 466= 467= 468= 469
= 470= 471= 472= 473= 474= 475= 476= 477= 478= 479
= 480= 481= 482= 483= 484= 485= 486= 487= 488= 489
= 490= 491= 492= 493= 494= 495= 496= 497= 498= 499
= 500</pre>

=={{header|Forth}}==
{{works with|Gforth}}
<lang forth>\ 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</lang>

{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44
45 46 47 58 59 60 61 62 63 74 75 76 77 78 79
90 91 92 93 94 95 106 107 108 109 110 111 122 123 124
125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
250 251 252 253 254 255 266 267 268 269 270 271 282 283 284
285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364
365 366 367 378 379 380 381 382 383 394 395 396 397 398 399
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500

301 such numbers found.
</pre>

=={{header|Go}}==
{{trans|Wren}}
<lang go>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)
}</lang>

{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44
45 46 47 58 59 60 61 62 63 74 75 76 77 78 79
90 91 92 93 94 95 106 107 108 109 110 111 122 123 124
125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
250 251 252 253 254 255 266 267 268 269 270 271 282 283 284
285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364
365 366 367 378 379 380 381 382 383 394 395 396 397 398 399
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500

301 such numbers found.
</pre>

=={{header|Julia}}==
<lang julia>usesletters = filter(n -> begin s = string(n, base = 16); any(c -> c in s, collect("abcdef")) end, 1:500)

foreach(p -> print(rpad(p[2], 4), p[1] % 15 == 0 ? "\n" : ""), enumerate(usesletters))
</lang>{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44
45 46 47 58 59 60 61 62 63 74 75 76 77 78 79
90 91 92 93 94 95 106 107 108 109 110 111 122 123 124
125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
250 251 252 253 254 255 266 267 268 269 270 271 282 283 284
285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364
365 366 367 378 379 380 381 382 383 394 395 396 397 398 399
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
</pre>

=={{header|Nim}}==
<lang 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()</lang>

{{out}}
<pre>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 </pre>

=={{header|Perl}}==
<lang 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";</lang>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63
74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124
125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 160 161 162
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
253 254 255 266 267 268 269 270 271 282 283 284 285 286 287 298 299 300
301 302 303 314 315 316 317 318 319 330 331 332 333 334 335 346 347 348
349 350 351 362 363 364 365 366 367 378 379 380 381 382 383 394 395 396
397 398 399 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
497 498 499 500
</pre>


=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">above9</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">return</span> <span style="color: #7060A8;">max</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%x"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span><span style="color: #0000FF;">))></span><span style="color: #008000;">'9'</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">500</span><span style="color: #0000FF;">),</span><span style="color: #000000;">above9</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">sprint</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"found"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">))})</span>
<!--</lang>-->
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 ... 491 492 493 494 495 496 497 498 499 500 (301 found)
</pre>

=={{header|PL/M}}==
<lang plm>100H: /* SHOW NUMBERS THAT WHEN REPRESENTED IN HEX, HAVE AT LEAST 1 A-F DIGIT */
/* CP/M BDOS SYSTEM CALL */
BDOS: PROCEDURE( FN, V ); DECLARE FN BYTE, V ADDRESS; GOTO 5; END;
/* 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</lang>
{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
</pre>

=={{header|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.

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

# ⑭㉒⑱⑩⑰⑰⑳⑮⑱⑳⑩⑳⑱㉒㉑⑰㉒⑫⑭⑲⑯⑩㉔⑮⑰</lang>

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:

<lang perl6>put "{+$_} such numbers:\n", .batch(20)».fmt('%3d').join("\n")
given (^501).grep( { so any |.map: { .polymod(16 xx *) »>» 9 } } );</lang>
{{out}}
<pre>301 such numbers:
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500</pre>

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.

<lang perl6>use Base::Any;
put "Integers from 0 to 500 that when expressed in Base -16 in standard notation, contain an alphabetic: {+$_}\n",
.batch(20)».fmt('%3d').join("\n")
given (^501).grep( { .&to-base(-16).contains: /<[A..F]>/ } );</lang>
{{out}}
<pre>Integers from 0 to 500 that when expressed in Base -16 in standard notation, contain an alphabetic: 306
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</pre>

=={{header|REXX}}==
REXX automatically uses only uppercase when converting integers to hexadecimal, &nbsp; but the lowercase alphabetic letters where also included for boilerplate code.
<lang rexx>/*REXX pgm finds positive integers when shown in hexadecimal require an alphabetic glyph*/
parse arg n cols . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n = 501 /*Not specified? Then use the default.*/
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. */</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
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
</pre>

=={{header|Ring}}==
<lang 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
</lang>
{{out}}
<pre>
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...
</pre>

=={{header|Wren}}==
{{libheader|Wren-fmt}}
<lang ecmascript>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.")</lang>

{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44
45 46 47 58 59 60 61 62 63 74 75 76 77 78 79
90 91 92 93 94 95 106 107 108 109 110 111 122 123 124
125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
250 251 252 253 254 255 266 267 268 269 270 271 282 283 284
285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364
365 366 367 378 379 380 381 382 383 394 395 396 397 398 399
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500

301 such numbers found.
</pre>

=={{header|XPL0}}==
Borrowed masking concept from C++, which was much more elegant than my first solution.
<lang XPL0>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);
]</lang>

{{out}}
<pre>
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59
60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109
110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 266 267 268 269
270 271 282 283 284 285 286 287 298 299 300 301 302 303 314 315 316 317 318 319
330 331 332 333 334 335 346 347 348 349 350 351 362 363 364 365 366 367 378 379
380 381 382 383 394 395 396 397 398 399 410 411 412 413 414 415 416 417 418 419
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
500
301 such numbers found.
</pre>

Latest revision as of 14:20, 6 August 2021