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

m
m (→‎{{header|Wren}}: Minor tidy)
(19 intermediate revisions by 15 users not shown)
Line 4:
Find positive integers for which the base 16 (hexadecimal) representation does not contain any decimal digits '0'..'9', &nbsp; where &nbsp; '''n &nbsp; < &nbsp; 500<sub>10</sub>'''
<br><br>
 
=={{header|11l}}==
<syntaxhighlight lang="11l">L(n) 1..499
L(c) hex(n)
I c.is_digit()
L.break
L.was_no_break
print(n, end' ‘ ’)</syntaxhighlight>
 
{{out}}
<pre>
10 11 12 13 14 15 170 171 172 173 174 175 186 187 188 189 190 191 202 203 204 205 206 207 218 219 220 221 222 223 234 235 236 237 238 239 250 251 252 253 254 255 </pre>
 
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">BYTE FUNC IsHexWithoutDigits(INT x)
DO
IF x MOD 16<10 THEN
Line 28 ⟶ 40:
OD
PrintF("%E%EFound %I numbers between %I and %I",count,min,max)
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Numbers_in_base-16_representation_that_cannot_be_written_with_decimal_digits.png Screenshot from Atari 8-bit computer]
Line 36 ⟶ 48:
 
Found 42 numbers between 0 and 499
</pre>
 
=={{header|Ada}}==
<syntaxhighlight lang="ada">with Ada.Text_IO;
 
procedure Numbers_In_Base_16 is
 
package Natural_IO is new Ada.Text_IO.Integer_IO (Natural);
use Ada.Text_IO, Natural_IO;
 
function Is_Hex_Only (Value : Natural) return Boolean
is (Value = 0 or
(Value mod 16 >= 10 and then Is_Hex_Only (Value / 16)));
 
subtype Test_Range is Natural range 1 .. 499;
Count : Natural := 0;
begin
for A in Test_Range loop
if Is_Hex_Only (A) then
Count := Count + 1;
Put (A, Width => 3); Put (" = ");
Put (A, Width => 6, Base => 16); Put (" ");
if Count mod 5 = 0 then
New_Line;
end if;
end if;
end loop;
New_Line;
Default_Width := 0;
Put ("There are "); Put (Count);
Put (" numbers in range ");
Put (Test_Range'First); Put (" .. ");
Put (Test_Range'Last);
Put (" without decimal digits in hex representation.");
New_Line;
end Numbers_In_Base_16;</syntaxhighlight>
{{out}}
<pre>
10 = 16#A# 11 = 16#B# 12 = 16#C# 13 = 16#D# 14 = 16#E#
15 = 16#F# 170 = 16#AA# 171 = 16#AB# 172 = 16#AC# 173 = 16#AD#
174 = 16#AE# 175 = 16#AF# 186 = 16#BA# 187 = 16#BB# 188 = 16#BC#
189 = 16#BD# 190 = 16#BE# 191 = 16#BF# 202 = 16#CA# 203 = 16#CB#
204 = 16#CC# 205 = 16#CD# 206 = 16#CE# 207 = 16#CF# 218 = 16#DA#
219 = 16#DB# 220 = 16#DC# 221 = 16#DD# 222 = 16#DE# 223 = 16#DF#
234 = 16#EA# 235 = 16#EB# 236 = 16#EC# 237 = 16#ED# 238 = 16#EE#
239 = 16#EF# 250 = 16#FA# 251 = 16#FB# 252 = 16#FC# 253 = 16#FD#
254 = 16#FE# 255 = 16#FF#
There are 42 numbers in range 1 .. 499 without decimal digits in hex representation.
</pre>
 
=={{header|ALGOL 68}}==
Generates the numbers.
<langsyntaxhighlight lang="algol68">BEGIN # find numbers whose hex representation does not contain the digits 0-9 #
# generate and print the numbers up to 499 #
# 499 is 1F3 in hex, so we need to find numbers up to FF #
Line 56 ⟶ 116:
OD
OD
END</langsyntaxhighlight>
{{out}}
<pre>
Line 64 ⟶ 124:
250 251 252 253 254 255
</pre>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">nonDecimalNums: select 1..500 'x ->
empty? intersection digits.base:16 x @0..9
 
loop split.every: 7 nonDecimalNums 'x ->
print map x 's -> pad to :string s 4</syntaxhighlight>
 
{{out}}
 
<pre> 10 11 12 13 14 15 170
171 172 173 174 175 186 187
188 189 190 191 202 203 204
205 206 207 218 219 220 221
222 223 234 235 236 237 238
239 250 251 252 253 254 255</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f NUMBERS_IN_BASE-16_REPRESENTATION_THAT_CANNOT_BE_WRITTEN_WITH_DECIMAL_DIGITS.AWK
BEGIN {
Line 79 ⟶ 156:
exit(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 91 ⟶ 168:
 
=={{header|BASIC}}==
<langsyntaxhighlight lang="basic">10 DEFINT A-Z
20 H=0: GOSUB 50
30 FOR H=10 TO 15: GOSUB 50: NEXT
Line 98 ⟶ 175:
60 PRINT H*16+L,
70 NEXT
80 RETURN</langsyntaxhighlight>
{{out}}
<pre> 10 11 12 13 14
Line 109 ⟶ 186:
239 250 251 252 253
254 255</pre>
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="basic256">global fila
fila = 0
n = 0
 
print "Numbers in base-16 representation that cannot be written with decimal digits:"
call num(n)
for n = 10 to 15
call num(n)
next n
print "Found "; fila; " numbers"
end
 
subroutine num(n)
for i = 10 to 15
print n * 16 + i; " ";
fila += 1
next i
print
end subroutine</syntaxhighlight>
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">Dim Shared As Integer fila = 0
Print "Numbers in base-16 representation that cannot be written with decimal digits:"
 
Sub num(n As Integer)
For i As Integer = 10 To 15
Print Using " #### "; n * 16 + i;
fila += 1
Next i
Print
End Sub
 
Dim As Integer n = 0
num(n)
For n = 10 To 15
num(n)
Next n
 
Print !"\nFound "; fila; " numbers"
Sleep</syntaxhighlight>
{{out}}
<pre>Numbers in base-16 representation that cannot be written with decimal digits:
10 11 12 13 14 15
170 171 172 173 174 175
186 187 188 189 190 191
202 203 204 205 206 207
218 219 220 221 222 223
234 235 236 237 238 239
250 251 252 253 254 255
 
Found 42 numbers</pre>
 
==={{header|PureBasic}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="purebasic">Global fila.i = 0
 
Procedure num(n.i)
For i = 10 To 15
Print(" " + Str(n * 16 + i) + " ")
fila + 1
Next i
PrintN("")
EndProcedure
 
 
OpenConsole()
PrintN("Numbers in base-16 representation that cannot be written with decimal digits:")
 
n.i = 0
num(n)
 
For n = 10 To 15
num(n)
Next n
PrintN(#CRLF$ + "Found " + Str(fila) + " numbers")
 
Input()
CloseConsole()
End</syntaxhighlight>
 
==={{header|True BASIC}}===
{{trans|BASIC256}}
<syntaxhighlight lang="qbasic">SUB num(n)
FOR i = 10 to 15
PRINT n * 16 + i; " ";
LET fila = fila + 1
NEXT i
PRINT
END SUB
 
PRINT "Numbers in base-16 representation that cannot be written with decimal digits:"
 
LET fila = 0
LET n = 0
CALL NUM(n)
FOR n = 10 to 15
CALL NUM(n)
NEXT n
PRINT "Found "; fila; " numbers"
END</syntaxhighlight>
 
==={{header|Yabasic}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="yabasic">print "Numbers in base-16 representation that cannot be written with decimal digits:"
fila = 0
n = 0
num(n)
for n = 10 to 15
num(n)
next n
print "\nFound ", fila, " numbers"
end
 
sub num(n)
for i = 10 to 15
print n * 16 + i using "####",
fila = fila + 1
next i
print
end sub</syntaxhighlight>
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let lownybble(hi) be
Line 121 ⟶ 322:
for hi=#XA to #XF do
lownybble(hi)
$)</langsyntaxhighlight>
{{out}}
<pre style="height:24em">10
Line 165 ⟶ 366:
254
255</pre>
 
=={{header|BQN}}==
<syntaxhighlight lang="bqn">∾⟜(16⊸×⊸+⌜˜) 10+↕6</syntaxhighlight>
{{out}}
<pre>┌─
╵ 10 11 12 13 14 15
170 171 172 173 174 175
186 187 188 189 190 191
202 203 204 205 206 207
218 219 220 221 222 223
234 235 236 237 238 239
250 251 252 253 254 255
┘</pre>
 
=={{header|C}}==
<syntaxhighlight lang="c">
<lang C>
#include<stdio.h>
 
Line 182 ⟶ 396:
return 0;
}
</syntaxhighlight>
</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 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
</pre>
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">
#include<iostream>
using namespace std;
Line 204 ⟶ 419:
return 0;
}
</syntaxhighlight>
</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 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
</pre>
=={{header|CLU}}==
<syntaxhighlight lang="clu">lownybble = proc (s: stream, hi: int)
for lo: int in int$from_to(10, 15) do
stream$putl(s, int$unparse(hi*16 + lo))
end
end lownybble
 
start_up = proc ()
po: stream := stream$primary_output()
lownybble(po, 0)
for hi: int in int$from_to(10, 15) do
lownybble(po, hi)
end
end start_up</syntaxhighlight>
{{out}}
<pre style='height:50ex;'>10
11
12
13
14
15
170
171
172
173
174
175
186
187
188
189
190
191
202
203
204
205
206
207
218
219
220
221
222
223
234
235
236
237
238
239
250
251
252
253
254
255</pre>
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. NO-0-9-IN-HEX.
Line 235 ⟶ 508:
ADD LOW-NYBBLE TO OUT-NUM.
MOVE OUT-NUM TO OUT-FMT.
DISPLAY OUT-FMT.</langsyntaxhighlight>
{{out}}
<pre style='height:24em;'> 10
Line 280 ⟶ 553:
255
</pre>
 
=={{header|Cowgol}}==
<syntaxhighlight lang="cowgol">include "cowgol.coh";
 
sub lownybble(hi: uint8) is
var lo: uint8 := 0xA;
while lo <= 0xF loop
print_i8(hi<<4 | lo);
print_nl();
lo := lo + 1;
end loop;
end sub;
 
lownybble(0);
var hi: uint8 := 0xA;
while hi <= 0xF loop;
lownybble(hi);
hi := hi + 1;
end loop;</syntaxhighlight>
{{out}}
<pre style='height:50ex;'>10
11
12
13
14
15
170
171
172
173
174
175
186
187
188
189
190
191
202
203
204
205
206
207
218
219
220
221
222
223
234
235
236
237
238
239
250
251
252
253
254
255</pre>
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc nonrec lownybble(word hi) void:
word lo;
for lo from 0xA upto 0xF do
writeln(hi<<4 | lo)
od
corp
 
proc nonrec main() void:
word hi;
lownybble(0);
for hi from 0xA upto 0xF do
lownybble(hi)
od
corp</syntaxhighlight>
{{out}}
<pre style='height:50ex;'>10
11
12
13
14
15
170
171
172
173
174
175
186
187
188
189
190
191
202
203
204
205
206
207
218
219
220
221
222
223
234
235
236
237
238
239
250
251
252
253
254
255</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
 
<syntaxhighlight lang="Delphi">
 
function HasNoBase10(N: integer): boolean;
{Test N for decimal digits in hex string}
var I: integer;
var S: string;
begin
Result:=False;
S:=Format('%x',[N]);
for I:=1 to Length(S) do
if S[I] in ['0'..'9'] then exit;
Result:=True;
end;
 
 
 
procedure ShowNoBase10inHex(Memo: TMemo);
var I,Cnt: integer;
var S: string;
begin
Cnt:=0;
for I:=0 to 500-1 do
if HasNoBase10(I) then
begin
Inc(Cnt);
S:=S+Format('%8D',[I]);
If (Cnt mod 5)=0 then S:=S+#$0D#$0A;
end;
Memo.Lines.Add('Count='+IntToStr(Cnt));
Memo.Lines.Add(S);
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
Count=42
10 11 12 13 14
15 170 171 172 173
174 175 186 187 188
189 190 191 202 203
204 205 206 207 218
219 220 221 222 223
234 235 236 237 238
239 250 251 252 253
254 255
</pre>
 
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// Base16 numbers represented using only digits greater than 9. Nigel Galloway: June 25th., 2021
let rec fG n g=seq{yield! g; yield! fG n (g|>List.collect(fun g->n|>List.map(fun n->n+g*16)))}
fG [10..15] [10..15]|>Seq.takeWhile((>)5000)|>Seq.iter(fun n->printf "%d(%0x) " n n); printfn ""
</syntaxhighlight>
</lang>
{{out}}
<pre>
10(a) 11(b) 12(c) 13(d) 14(e) 15(f) 170(aa) 171(ab) 172(ac) 173(ad) 174(ae) 175(af) 186(ba) 187(bb) 188(bc) 189(bd) 190(be) 191(bf) 202(ca) 203(cb) 204(cc) 205(cd) 206(ce) 207(cf) 218(da) 219(db) 220(dc) 221(dd) 222(de) 223(df) 234(ea) 235(eb) 236(ec) 237(ed) 238(ee) 239(ef) 250(fa) 251(fb) 252(fc) 253(fd) 254(fe) 255(ff) 2730(aaa) 2731(aab) 2732(aac) 2733(aad) 2734(aae) 2735(aaf) 2746(aba) 2747(abb) 2748(abc) 2749(abd) 2750(abe) 2751(abf) 2762(aca) 2763(acb) 2764(acc) 2765(acd) 2766(ace) 2767(acf) 2778(ada) 2779(adb) 2780(adc) 2781(add) 2782(ade) 2783(adf) 2794(aea) 2795(aeb) 2796(aec) 2797(aed) 2798(aee) 2799(aef) 2810(afa) 2811(afb) 2812(afc) 2813(afd) 2814(afe) 2815(aff) 2986(baa) 2987(bab) 2988(bac) 2989(bad) 2990(bae) 2991(baf) 3002(bba) 3003(bbb) 3004(bbc) 3005(bbd) 3006(bbe) 3007(bbf) 3018(bca) 3019(bcb) 3020(bcc) 3021(bcd) 3022(bce) 3023(bcf) 3034(bda) 3035(bdb) 3036(bdc) 3037(bdd) 3038(bde) 3039(bdf) 3050(bea) 3051(beb) 3052(bec) 3053(bed) 3054(bee) 3055(bef) 3066(bfa) 3067(bfb) 3068(bfc) 3069(bfd) 3070(bfe) 3071(bff) 3242(caa) 3243(cab) 3244(cac) 3245(cad) 3246(cae) 3247(caf) 3258(cba) 3259(cbb) 3260(cbc) 3261(cbd) 3262(cbe) 3263(cbf) 3274(cca) 3275(ccb) 3276(ccc) 3277(ccd) 3278(cce) 3279(ccf) 3290(cda) 3291(cdb) 3292(cdc) 3293(cdd) 3294(cde) 3295(cdf) 3306(cea) 3307(ceb) 3308(cec) 3309(ced) 3310(cee) 3311(cef) 3322(cfa) 3323(cfb) 3324(cfc) 3325(cfd) 3326(cfe) 3327(cff) 3498(daa) 3499(dab) 3500(dac) 3501(dad) 3502(dae) 3503(daf) 3514(dba) 3515(dbb) 3516(dbc) 3517(dbd) 3518(dbe) 3519(dbf) 3530(dca) 3531(dcb) 3532(dcc) 3533(dcd) 3534(dce) 3535(dcf) 3546(dda) 3547(ddb) 3548(ddc) 3549(ddd) 3550(dde) 3551(ddf) 3562(dea) 3563(deb) 3564(dec) 3565(ded) 3566(dee) 3567(def) 3578(dfa) 3579(dfb) 3580(dfc) 3581(dfd) 3582(dfe) 3583(dff) 3754(eaa) 3755(eab) 3756(eac) 3757(ead) 3758(eae) 3759(eaf) 3770(eba) 3771(ebb) 3772(ebc) 3773(ebd) 3774(ebe) 3775(ebf) 3786(eca) 3787(ecb) 3788(ecc) 3789(ecd) 3790(ece) 3791(ecf) 3802(eda) 3803(edb) 3804(edc) 3805(edd) 3806(ede) 3807(edf) 3818(eea) 3819(eeb) 3820(eec) 3821(eed) 3822(eee) 3823(eef) 3834(efa) 3835(efb) 3836(efc) 3837(efd) 3838(efe) 3839(eff) 4010(faa) 4011(fab) 4012(fac) 4013(fad) 4014(fae) 4015(faf) 4026(fba) 4027(fbb) 4028(fbc) 4029(fbd) 4030(fbe) 4031(fbf) 4042(fca) 4043(fcb) 4044(fcc) 4045(fcd) 4046(fce) 4047(fcf) 4058(fda) 4059(fdb) 4060(fdc) 4061(fdd) 4062(fde) 4063(fdf) 4074(fea) 4075(feb) 4076(fec) 4077(fed) 4078(fee) 4079(fef) 4090(ffa) 4091(ffb) 4092(ffc) 4093(ffd) 4094(ffe) 4095(fff)
</pre>
 
=={{header|Factor}}==
Count up by letters A-F; convert from hexadecimal to decimal.
{{works with|Factor|0.99 2021-06-02}}
<langsyntaxhighlight lang="factor">USING: kernel math.combinatorics math.parser prettyprint
sequences.extras ;
 
"ABCDEF" { 1 2 } [ [ hex> ] map-selections ] with map-concat .</langsyntaxhighlight>
{{out}}
<pre style="height:24em">
Line 344 ⟶ 793:
255
}
</pre>
 
=={{header|Frink}}==
<syntaxhighlight lang="frink">println[select[1 to 500, {|x| base16[x] =~ %r/^[a-z]+$/i} ]]</syntaxhighlight>
{{out}}
<pre>
[10, 11, 12, 13, 14, 15, 170, 171, 172, 173, 174, 175, 186, 187, 188, 189, 190, 191, 202, 203, 204, 205, 206, 207, 218, 219, 220, 221, 222, 223, 234, 235, 236, 237, 238, 239, 250, 251, 252, 253, 254, 255]
</pre>
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
import (
Line 369 ⟶ 825:
}
fmt.Printf("\n%d such numbers found.\n", c)
}</langsyntaxhighlight>
 
{{out}}
Line 380 ⟶ 836:
</pre>
 
 
=={{header|Haskell}}==
<syntaxhighlight lang="haskell">-- With the exception of an initial 0, this is a list of all numbers whose
-- base-16 representations contain no decimal digits.
allNonDecimal :: [Int]
allNonDecimal = 0 : concatMap mulAdd allNonDecimal
where mulAdd n = let m = n * 16 in map (m +) [10..15]
 
main :: IO ()
main = print $ takeWhile (< 500) $ tail allNonDecimal</syntaxhighlight>
{{out}}
<pre>
$ no_dec
[10,11,12,13,14,15,170,171,172,173,174,175,186,187,188,189,190,191,202,203,204,205,206,207,218,219,220,221,222,223,234,235,236,237,238,239,250,251,252,253,254,255]
</pre>
 
=={{header|J}}==
 
Represented as decimal numbers:<syntaxhighlight lang="j"> I.(9 */ .< 16 #.inv ])"0 i.500
10 11 12 13 14 15 170 171 172 173 174 175 186 187 188 189 190 191 202 203 204 205 206 207 218 219 220 221 222 223 234 235 236 237 238 239 250 251 252 253 254 255</syntaxhighlight>
 
Represented as hexadecimal numbers:<syntaxhighlight lang="j"> require'convert'
;:inv hfd each I.(9 */ .< 16 #.inv ])"0 i.500
a b c d e f aa ab ac ad ae af ba bb bc bd be bf ca cb cc cd ce cf da db dc dd de df ea eb ec ed ee ef fa fb fc fd fe ff</syntaxhighlight>
 
=={{header|jq}}==
{{works with|jq}}
'''Also works with gojq, the Go implementation of jq, and with fq'''
<syntaxhighlight lang=jq>
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
 
def hex_stream:
recurse(if . >= 16 then ./16|floor else empty end) | . % 16 ;
 
# Emit a stream of the decimal integers in range(1; $upper+1) satisfying the condition
def no_hex_digits($upper):
range(1; $upper)
| select( all(hex_stream; . > 9) );
 
[no_hex_digits(500)]
| (_nwise(14) | map(lpad(3)) | join(" ")),
"\n\(length) such numbers found."
</syntaxhighlight>
{{output}}
<pre>
10 11 12 13 14 15 170 171 172 173 174 175 186 187
188 189 190 191 202 203 204 205 206 207 218 219 220 221
222 223 234 235 236 237 238 239 250 251 252 253 254 255
 
42 such numbers found.
</pre>
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">usesnoletters = filter(n -> begin s = string(n, base = 16); all(c -> c in "abcdef", s) end, 1:500)
 
foreach(p -> print(rpad(p[2], 4), p[1] % 14 == 0 ? "\n" : ""), enumerate(usesnoletters))
</langsyntaxhighlight>{{out}}
<pre>
10 11 12 13 14 15 170 171 172 173 174 175 186 187
Line 391 ⟶ 898:
222 223 234 235 236 237 238 239 250 251 252 253 254 255
</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">Cases[Range[
500], _?(Length@Intersection[IntegerDigits[#, 16], Range[0, 9]] ==
0 &)]</langsyntaxhighlight>
 
{{out}}<pre>
{10,11,12,13,14,15,170,171,172,173,174,175,186,187,188,189,190,191,202,203,204,205,206,207,218,219,220,221,222,223,234,235,236,237,238,239,250,251,252,253,254,255}
</pre>
 
=={{header|Modula-2}}==
<syntaxhighlight lang="modula2">MODULE Base16NoDecimalNumbers;
FROM InOut IMPORT WriteCard, WriteLn;
 
VAR hi: CARDINAL;
 
PROCEDURE LowNybble(hi: CARDINAL);
VAR lo: CARDINAL;
BEGIN
FOR lo := 10 TO 15 DO
WriteCard(hi*16 + lo, 3);
WriteLn
END
END LowNybble;
 
BEGIN
LowNybble(0);
FOR hi := 10 TO 15 DO
LowNybble(hi)
END
END Base16NoDecimalNumbers.</syntaxhighlight>
{{out}}
<pre style='height:50ex;'>10
11
12
13
14
15
170
171
172
173
174
175
186
187
188
189
190
191
202
203
204
205
206
207
218
219
220
221
222
223
234
235
236
237
238
239
250
251
252
253
254
255</pre>
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import strutils, sugar
 
let list = collect(newSeq):
Line 410 ⟶ 983:
echo "Found ", list.len, " numbers < 500 which cannot be written in base 16 with decimal digits:"
for i, n in list:
stdout.write ($n).align(3), if (i + 1) mod 7 == 0: '\n' else: ' '</langsyntaxhighlight>
 
{{out}}
Line 422 ⟶ 995:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">use strict;
use warnings;
 
print join( ' ', grep sprintf("%x", $_) !~ /[0-9]/, 1 .. 500 ) =~ s/.{71}\K /\n/gr, "\n";</langsyntaxhighlight>
{{out}}
<pre>10 11 12 13 14 15 170 171 172 173 174 175 186 187 188 189 190 191 202 203
Line 433 ⟶ 1,006:
=={{header|Phix}}==
[[Base-16_representation#Phix|Spot the difference...]]
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">above9</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">return</span> <span style="color: #7060A8;">min</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%x"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span><span style="color: #0000FF;">))></span><span style="color: #008000;">'9'</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">500</span><span style="color: #0000FF;">),</span><span style="color: #000000;">above9</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">sprint</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"found"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">))})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 444 ⟶ 1,017:
 
=={{header|PL/M}}==
<langsyntaxhighlight lang="pli">100H: /* FIND NUMBERS WHOSE HEX REPRESENTATION DOES NOT CONTAIN DIGITS 0-9 */
BDOS: PROCEDURE( FN, ARG ); /* CP/M BDOS SYSTEM CALL */
DECLARE FN BYTE, ARG ADDRESS;
Line 486 ⟶ 1,059:
END;
END;
EOF</langsyntaxhighlight>
{{out}}
<pre>
Line 496 ⟶ 1,069:
 
=={{header|Python}}==
<syntaxhighlight lang="python">
<lang Python>
[print(16*q + r,end=' ') for q in range(0,16) for r in range(10,16)]
</syntaxhighlight>
</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 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
</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="quackery"> [ true swap
[ 16 /mod 10 < iff
[ dip not ] done
dup 0 = until ]
drop ] is nodigits ( n --> b )
 
[] 500 times
[ i^ nodigits if
[ i^ join ] ]
 
say "In decimal." cr
dup echo cr cr
say "In hexadecimal."cr
16 base put
echo cr
base release</syntaxhighlight>
 
{{out}}
 
<pre>In decimal.
[ 10 11 12 13 14 15 170 171 172 173 174 175 186 187 188 189 190 191 202 203 204 205 206 207 218 219 220 221 222 223 234 235 236 237 238 239 250 251 252 253 254 255 ]
 
In hexadecimal.
[ A B C D E F AA AB AC AD AE AF BA BB BC BD BE BF CA CB CC CD CE CF DA DB DC DD DE DF EA EB EC ED EE EF FA FB FC FD FE FF ]
</pre>
 
=={{header|Raku}}==
<blockquote>Find numbers in base-16 representation that cannot be written with decimal digits, where n < 500</blockquote>
Line 513 ⟶ 1,115:
The task as written:
 
<syntaxhighlight lang="raku" perl6line>put "{+$_} such numbers:\n", .batch(20)».fmt('%3d').join("\n")
given (1..500).grep( { so any |.map: { .polymod(16 xx *) »>» 9 } } );</langsyntaxhighlight>
{{out}}
<pre>301 such numbers:
Line 541 ⟶ 1,143:
Which is a '''tiny''' (2 character) change from [[Base-16 representation]]. Add some other (possibly useful) functionality.
 
<syntaxhighlight lang="raku" perl6line>#Filter out such numbers from a range:
put "Filter: {+$_} such numbers:\n", .batch(20)».fmt('%3d').join("\n")
given (1..500).grep( { so all |.map: { .polymod(16 xx *) »>» 9 } } );
Line 552 ⟶ 1,154:
my $upto = 500;
put "\nCount: " ~ [+] flat (map {exp($_, 6)}, 1..($upto.log(16).floor)),
+(exp($upto.log(16).floor, 16) .. $upto).grep( { so all |.map: { .polymod(16 xx *) »>» 9 } });</langsyntaxhighlight>
{{out}}
<pre>Filter: 42 such numbers:
Line 570 ⟶ 1,172:
=={{header|REXX}}==
=== version 1 ===
<langsyntaxhighlight lang="rexx">/*REXX pgm finds positive integers when shown in hex that can't be written with dec digs*/
parse arg n cols . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n = 500 /*Not specified? Then use the default.*/
Line 594 ⟶ 1,196:
say
say 'Found ' found title
exit 0 /*stick a fork in it, we're all done. */</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 611 ⟶ 1,213:
=== version 2 ===
This REXX version is exactly the same as version 1, &nbsp; but the &nbsp; ''filter'' &nbsp; was "inverted" so as to achieve the same result.
<langsyntaxhighlight lang="rexx">/*REXX pgm finds positive integers when shown in hex that can't be written with dec digs*/
parse arg n cols . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n = 500 /*Not specified? Then use the default.*/
Line 635 ⟶ 1,237:
say
say 'Found ' found title
exit 0 /*stick a fork in it, we're all done. */</langsyntaxhighlight>
{{out|output|text=&nbsp; is identical to the 1<sup>st</sup> REXX version.}} <br><br>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
see "working..." + nl
see "Numbers in base-16 representation that cannot be written with decimal digits:" + nl
Line 669 ⟶ 1,271:
see nl + "Found " + row + " numbers" + nl
see "done..." + nl
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 685 ⟶ 1,287:
Found 42 numbers
done...
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
≪ { 0 10 11 12 13 14 15 } → abc
≪ { }
1 7 '''FOR''' a 1 7 '''FOR''' b 2 7 '''FOR''' c
abc a GET 256 * abc b GET 16 * + abc c GET +
'''IF''' DUP 500 ≤ '''THEN''' + '''ELSE''' DROP '''END'''
'''NEXT NEXT NEXT'''
≫ ≫ ''''TASK'''' STO
{{out}}
<pre>
1: { 10 11 12 13 14 15 170 171 172 173 174 175 186 187 188 189 190 191 202 203 204 205 206 207 218 219 220 221 222 223 234 235 236 237 238 239 250 251 252 253 254 255 }
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">p (0..500).select{|n| n.digits(16).all?{|d| d > 9} }</syntaxhighlight>
{{out}}
<pre>
[10, 11, 12, 13, 14, 15, 170, 171, 172, 173, 174, 175, 186, 187, 188, 189, 190, 191, 202, 203, 204, 205, 206, 207, 218, 219, 220, 221, 222, 223, 234, 235, 236, 237, 238, 239, 250, 251, 252, 253, 254, 255]
</pre>
 
=={{header|Sidef}}==
Simple solution:
<langsyntaxhighlight lang="ruby">1..500 -> grep { .digits(16).min >= 10 }.say</langsyntaxhighlight>
 
More efficient approach:
<langsyntaxhighlight lang="ruby">func generate_from_prefix(limit, p, base, digits) {
 
var seq = [p]
Line 713 ⟶ 1,336:
}
 
say numbers_with_non_decimal_digits(500, 16)</langsyntaxhighlight>
{{out}}
<pre>
Line 720 ⟶ 1,343:
 
=={{header|UNIX Shell}}==
<langsyntaxhighlight lang="bash">
for q in {0..15};do for r in {10..15};do echo -n $((16*q+r));done;done
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 730 ⟶ 1,353:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<langsyntaxhighlight ecmascriptlang="wren">import "./fmt" for Conv, Fmt
var decimal = "0123456789"
Line 742 ⟶ 1,365:
}
}
System.print("\n%(c) such numbers found.")</langsyntaxhighlight>
 
{{out}}
Line 754 ⟶ 1,377:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">func Hexed(N); \Return 'true' if N contains a hex digit
int N;
[while N do
Line 776 ⟶ 1,399:
Text(0, " such numbers found.
");
]</langsyntaxhighlight>
 
{{out}}
9,476

edits