Numbers with same digit set in base 10 and base 16

Revision as of 13:01, 17 June 2021 by rosettacode>Horsth (added pascal)

Find decimal numbers   n   that when converted to hexadecimal produce a number that uses the same set of digits (regardless of order and ignoring duplicates) as the original number,   where   n  <  100000

Numbers with same digit set in base 10 and base 16 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


Example

The decimal number   2339   is   923   when written in hexadecimal.

The set of digits used,   ignoring order and duplicates,   is   {2, 3, 9}   in both cases and hence this number satisfies the task requirements.

ALGOL W

Generates the candidate numbers (ones that only have the digits 0-9 in their hexadecimal representation) to cut down the numbers to check. <lang algolw>begin % find numbers that use the same digits in decimal and hexadecimal  %

   integer hdCount, h20, h300, h4000, h50000;
   logical array hex, dec ( 0 :: 9 );
   integer x2, x3, x4, x5, hx2, hx3, hx4, hx5;
   hdCount := 0;
   % note 100 000 is 186A0 in hexadecimal, so we need to consider numbers    %
   % with up to 5 hexadedcimal digits                                        %
   % powers of 16 %
   x2 := 16; x3 := x2 * 16; x4 := x3 * 16; x5 := x4 * 16;
   for hPos := 0 until 9 do hex( hPos ) := false;
   % construct the numbers that have only 0-9 in their hex representations   %
   for h5 := 0 until 1 do begin
       hx5 := h5 * x5;
       for h4 := 0 until 9 do begin
           hx4 := h4 * x4;
           for h3 := 0 until 9 do begin
               hx3 := h3 * x3;
               for h2 := 0 until 9 do begin
                   hx2 := h2 * x2;
                   for h1 := 0 until 9 do begin
                       integer n, d;
                       n := d := hx5 + hx4 + hx3 + hx2 + h1;
                       if n > 100000 then goto endSearch;
                       for dPos := 0 until 9 do dec( dPos ) := false;
                       if d = 0 then dec( 0 ) := true;
                       while d > 0 do begin
                           dec( d rem 10 ) := true;
                           d := d div 10
                       end while_d_gt_0 ;
                       if h5 not = 0                then hex( h5 ) := true;
                       if h5 + h4 not = 0           then hex( h4 ) := true;
                       if h5 + h4 + h3 not = 0      then hex( h3 ) := true;
                       if h5 + h4 + h3 + h2 not = 0 then hex( h2 ) := true;
                       hex( h1 ) := true;
                       if  hex( 0 ) = dec( 0 ) and hex( 1 ) = dec( 1 )
                       and hex( 2 ) = dec( 2 ) and hex( 3 ) = dec( 3 )
                       and hex( 4 ) = dec( 4 ) and hex( 5 ) = dec( 5 )
                       and hex( 6 ) = dec( 6 ) and hex( 7 ) = dec( 7 )
                       and hex( 8 ) = dec( 8 ) and hex( 9 ) = dec( 9 )
                       then begin
                           % the decimal and hexadecimal representations     %
                           % use the same digits                             %
                           writeon( i_w := 7, s_w := 0, " ", n );
                           hdCount := hdCount + 1;
                           if hdCount rem 10 = 0 then write()
                       end if_allSame ;
                       hex( h1 ) := false;
                       hex( h2 ) := false;
                       hex( h3 ) := false;        
                       hex( h4 ) := false;
                       hex( h5 ) := false;
                   end for_h5
               end for_h4
           end for_h3
       end for_h2
   end for_h1 ;

endSearch:

   write( i_w := 1, s_w := 0, "Found ", hdCount, " numbers up to 100000 " );
   write( "      where the decimal and hexadecimal "
        , "representations use the same digits"
        );

end.</lang>

Output:
       0       1       2       3       4       5       6       7       8       9
      53     371     913    1040    2080    2339    4100    5141    5412    5441
    6182    8200    9241   13593   13665   13969   16406   20530   26946   30979
   32803   33638   33840   33841   33842   33843   33844   33845   33846   33847
   33848   33849   34883   37943   38931   38966   38995   66310   71444   71497
   71511   75120   75121   75122   75123   75124   75125   75126   75127   75128
   75129   75621   86150   88165   91465   91769   96617   98711   99481
Found 69 numbers up to 100000
      where the decimal and hexadecimal representations use the same digits

APL

Works with: Dyalog APL

<lang APL>(⊢(/⍨)(≡/((⊂∘⍋⌷⊢)∘∪¨10 16(⊥⍣¯1)¨⊂))¨)0,⍳99999</lang>

Output:
0 1 2 3 4 5 6 7 8 9 53 371 913 1040 2080 2339 4100 5141 5412 5441 6182
      8200 9241 13593 13665 13969 16406 20530 26946 30979 32803 33638
      33840 33841 33842 33843 33844 33845 33846 33847 33848 33849 34883
      37943 38931 38966 38995 66310 71444 71497 71511 75120 75121 75122
      75123 75124 75125 75126 75127 75128 75129 75621 86150 88165 91465
      91769 96617 98711 99481

AppleScript

<lang applescript>use AppleScript version "2.3.1" -- Mac OS X 10.9 (Mavericks) or later. use sorter : script "Insertion sort" -- <https://www.rosettacode.org/wiki/Sorting_algorithms/Insertion_sort#AppleScript>

on sameDigitSetDecHex(n)

   (* Integer number input assumed.
      Numbers whose hex LSD > 9 are eliminated immediately. Ditto negatives.
      Thereafter the hex form's tested first so that the dec form doesn't have to be if the hex is unsuitable. *)
   tell n mod 16 to if ((it > 9) or (it < 0)) then return false
   
   script o
       on digitsOf(n, base)
           set digits to {n mod base}
           set n to n div base
           repeat until (n = 0)
               set d to n mod base
               if (d > 9) then return false
               if (d is not in digits) then set end of digits to d
               set n to n div base
           end repeat
           tell sorter to sort(digits, 1, -1)
           
           return digits
       end digitsOf
   end script
   
   tell o's digitsOf(n, 16) to return ((it is not false) and (it = o's digitsOf(n, 10)))

end sameDigitSetDecHex

local output, n set output to {} repeat with n from 0 to 99999

   if (sameDigitSetDecHex(n)) then set end of output to n

end repeat return output</lang>

Output:

<lang applescript>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 53, 371, 913, 1040, 2080, 2339, 4100, 5141, 5412, 5441, 6182, 8200, 9241, 13593, 13665, 13969, 16406, 20530, 26946, 30979, 32803, 33638, 33840, 33841, 33842, 33843, 33844, 33845, 33846, 33847, 33848, 33849, 34883, 37943, 38931, 38966, 38995, 66310, 71444, 71497, 71511, 75120, 75121, 75122, 75123, 75124, 75125, 75126, 75127, 75128, 75129, 75621, 86150, 88165, 91465, 91769, 96617, 98711, 99481}</lang>

AWK

<lang AWK>

  1. syntax: GAWK -f DECIMAL_-_HEXADECIMAL_NUMBERS.AWK

BEGIN {

   start = 0
   stop = 99999
   for (i=start; i<=stop; i++) {
     tmp = sprintf("%X",i)
     leng_dec = length(i)
     leng_hex = length(tmp)
     hits_dec = hits_hex = 0
     for (j=1; j<=leng_dec; j++) {
       if (tmp ~ substr(i,j,1)) {
         hits_dec++
       }
     }
     if (leng_dec == hits_dec) {
       for (j=1; j<=leng_hex; j++) {
         if (i ~ substr(tmp,j,1)) {
           hits_hex++
         }
       }
     }
     if (leng_hex == hits_hex) {
       printf("%6d%1s",i,++count%10?"":"\n")
     }
   }
   printf("\nDecimal matches hexadecimal %d-%d: %d\n",start,stop,count)
   exit(0)

} </lang>

Output:
     0      1      2      3      4      5      6      7      8      9
    53    371    913   1040   2080   2339   4100   5141   5412   5441
  6182   8200   9241  13593  13665  13969  16406  20530  26946  30979
 32803  33638  33840  33841  33842  33843  33844  33845  33846  33847
 33848  33849  34883  37943  38931  38966  38995  66310  71444  71497
 71511  75120  75121  75122  75123  75124  75125  75126  75127  75128
 75129  75621  86150  88165  91465  91769  96617  98711  99481
Decimal matches hexadecimal 0-99999: 69

C

<lang c>#include <stdio.h>

  1. define LIMIT 100000

int digitset(int num, int base) {

   int set;
   for (set = 0; num; num /= base)
       set |= 1 << num % base;
   return set;

}

int main() {

   int i, c = 0;
   for (i = 0; i < LIMIT; i++)
       if (digitset(i,10) == digitset(i,16))
           printf("%6d%c", i, ++c%10 ? ' ' : '\n');
   printf("\n");
   return 0;

}</lang>

Output:
     0      1      2      3      4      5      6      7      8      9
    53    371    913   1040   2080   2339   4100   5141   5412   5441
  6182   8200   9241  13593  13665  13969  16406  20530  26946  30979
 32803  33638  33840  33841  33842  33843  33844  33845  33846  33847
 33848  33849  34883  37943  38931  38966  38995  66310  71444  71497
 71511  75120  75121  75122  75123  75124  75125  75126  75127  75128
 75129  75621  86150  88165  91465  91769  96617  98711  99481

C++

<lang cpp>#include <iostream>

  1. include <iomanip>
  2. include <bitset>

const int LIMIT = 100000;

std::bitset<16> digitset(int num, int base) {

   std::bitset<16> set;
   for (; num; num /= base) set.set(num % base);
   return set;

}

int main() {

   int c = 0;
   for (int i=0; i<LIMIT; i++) {
       if (digitset(i,10) == digitset(i,16)) {
           std::cout << std::setw(7) << i;
           if (++c % 10 == 0) std::cout << std::endl;
       }
   }
   std::cout << std::endl;
   return 0;

}</lang>

Output:
      0      1      2      3      4      5      6      7      8      9
     53    371    913   1040   2080   2339   4100   5141   5412   5441
   6182   8200   9241  13593  13665  13969  16406  20530  26946  30979
  32803  33638  33840  33841  33842  33843  33844  33845  33846  33847
  33848  33849  34883  37943  38931  38966  38995  66310  71444  71497
  71511  75120  75121  75122  75123  75124  75125  75126  75127  75128
  75129  75621  86150  88165  91465  91769  96617  98711  99481

Cowgol

<lang cowgol>include "cowgol.coh";

const LIMIT := 100000;

sub digitset(n: uint32, base: uint8): (set: uint16) is

   var one: uint16 := 1;
   set := 0;
   while n != 0 loop
       set := set | (one << (n % base as uint32) as uint8);
       n := n / base as uint32;
   end loop;

end sub;

var i: uint32 := 0; var c: uint8 := 0; while i < LIMIT loop

   if digitset(i,10) == digitset(i,16) then
       print_i32(i);
       if c<9 then
           c := c + 1;
           print_char('\t');
       else
           c := 0;
           print_nl();
       end if;
   end if;
   i := i + 1;

end loop; print_nl();</lang>

Output:
0       1       2       3       4       5       6       7       8       9
53      371     913     1040    2080    2339    4100    5141    5412    5441
6182    8200    9241    13593   13665   13969   16406   20530   26946   30979
32803   33638   33840   33841   33842   33843   33844   33845   33846   33847
33848   33849   34883   37943   38931   38966   38995   66310   71444   71497
71511   75120   75121   75122   75123   75124   75125   75126   75127   75128
75129   75621   86150   88165   91465   91769   96617   98711   99481

F#

<lang fsharp> // Decimal-Hexdecimal: Nigel Galloway. June 7th., 2021 let rec fN g=function n when n<10->Some(Set.add n g)|n when n%16<10->fN(g.Add(n%16))(n/16) |_->None let rec fG n g=match n/10,n%10 with (0,n)->Some(Set.add n g)|(n,i)->fG n (Set.add i g) let g=Set.empty in seq{0..100000}|>Seq.filter(fun n->fN g n=fG n g)|>Seq.iter(printf "%d "); printfn "" </lang>

Output:
0 1 2 3 4 5 6 7 8 9 53 371 913 1040 2080 2339 4100 5141 5412 5441 6182 8200 9241 13593 13665 13969 16406 20530 26946 30979 32803 33638 33840 33841 33842 33843 33844 33845 33846 33847 33848 33849 34883 37943 38931 38966 38995 66310 71444 71497 71511 75120 75121 75122 75123 75124 75125 75126 75127 75128 75129 75621 86150 88165 91465 91769 96617 98711 99481

Factor

Works with: Factor version 0.99 2021-02-05

<lang factor>USING: formatting grouping io kernel math.parser present sequences sets ;

100,000 <iota> [ dup present swap >hex set= ] filter 10 group [ [ "%5d " printf ] each nl ] each</lang>

Output:
    0     1     2     3     4     5     6     7     8     9 
   53   371   913  1040  2080  2339  4100  5141  5412  5441 
 6182  8200  9241 13593 13665 13969 16406 20530 26946 30979 
32803 33638 33840 33841 33842 33843 33844 33845 33846 33847 
33848 33849 34883 37943 38931 38966 38995 66310 71444 71497 
71511 75120 75121 75122 75123 75124 75125 75126 75127 75128 
75129 75621 86150 88165 91465 91769 96617 98711 99481 

Go

Translation of: Wren

<lang go>package main

import (

   "fmt"
   "rcu"
   "strconv"

)

func equalSets(s1, s2 map[rune]bool) bool {

   if len(s1) != len(s2) {
       return false
   }
   for k, _ := range s1 {
       _, ok := s2[k]
       if !ok {
           return false
       }
   }
   return true

}

func main() {

   const limit = 100_000
   count := 0
   fmt.Println("Numbers under 100,000 which use the same digits in decimal or hex:")
   for n := 0; n < limit; n++ {
       h := strconv.FormatInt(int64(n), 16)
       hs := make(map[rune]bool)
       for _, c := range h {
           hs[c] = true
       }
       ns := make(map[rune]bool)
       for _, c := range strconv.Itoa(n) {
           ns[c] = true
       }
       if equalSets(hs, ns) {
           count++
           fmt.Printf("%6s ", rcu.Commatize(n))
           if count%10 == 0 {
               fmt.Println()
           }
       }
   }
   fmt.Printf("\n\n%d such numbers found.\n", count)

}</lang>

Output:
Numbers under 100,000 which use the same digits in decimal or hex:
     0      1      2      3      4      5      6      7      8      9 
    53    371    913  1,040  2,080  2,339  4,100  5,141  5,412  5,441 
 6,182  8,200  9,241 13,593 13,665 13,969 16,406 20,530 26,946 30,979 
32,803 33,638 33,840 33,841 33,842 33,843 33,844 33,845 33,846 33,847 
33,848 33,849 34,883 37,943 38,931 38,966 38,995 66,310 71,444 71,497 
71,511 75,120 75,121 75,122 75,123 75,124 75,125 75,126 75,127 75,128 
75,129 75,621 86,150 88,165 91,465 91,769 96,617 98,711 99,481 

69 such numbers found.

Julia

<lang julia>dhstring(N) = [i for i in 0:N if sort(unique(digits(i))) == sort(unique(digits(i, base=16)))]

foreach(p -> print(rpad(p[2], 6), p[1] % 10 == 0 ? "\n" : ""), enumerate(dhstring(100000)))

</lang>

Output:
0     1     2     3     4     5     6     7     8     9     
53    371   913   1040  2080  2339  4100  5141  5412  5441
6182  8200  9241  13593 13665 13969 16406 20530 26946 30979
32803 33638 33840 33841 33842 33843 33844 33845 33846 33847
33848 33849 34883 37943 38931 38966 38995 66310 71444 71497
71511 75120 75121 75122 75123 75124 75125 75126 75127 75128
75129 75621 86150 88165 91465 91769 96617 98711 99481

Nim

There are many ways to find the numbers. We chose to build directly the set of digits in base 10 and base 16 rather than using the string representations (more code but more efficient).

<lang Nim>import strutils, sugar

const Lim = 99_999

type Digit = 0..15

func digitSet(n: Natural; b: Positive): set[Digit] =

 ## Return the set of digits of "n" written in base "b".
 assert b <= 16
 if n == 0: return {Digit 0}
 var n = n
 while n != 0:
   result.incl n mod b
   n = n div b
  1. Build the list of numbers.

let list = collect(newSeq):

            for n in 0..Lim:
              if n.digitSet(10) == n.digitSet(16): n
  1. Display result.

echo "Found $1 numbers less than $2:".format(list.len, insertSep($(Lim + 1))) for i, n in list:

 stdout.write ($n).align(5), if (i + 1) mod 10 == 0: '\n' else: ' '

echo()</lang>

Output:
Found 69 numbers less than 100_000:
    0     1     2     3     4     5     6     7     8     9
   53   371   913  1040  2080  2339  4100  5141  5412  5441
 6182  8200  9241 13593 13665 13969 16406 20530 26946 30979
32803 33638 33840 33841 33842 33843 33844 33845 33846 33847
33848 33849 34883 37943 38931 38966 38995 66310 71444 71497
71511 75120 75121 75122 75123 75124 75125 75126 75127 75128
75129 75621 86150 88165 91465 91769 96617 98711 99481 

Pascal

simply adding 1 to a number and convert as if hex digits. <lang pascal>program Dec_Hex_same_UsedDigits; {$IFDEF FPC}

 {$MODE DELPHI}  {$OPTIMIZATION ON,ALL}  {$COPERATORS ON}

{$ELSE}

 {$APPTYPE CONSOLE}

{$ENDIF} const

 UpperLimit =  100*1000;//1000*1000*1000

type

 tUsedDigits = array[0..15] of byte;

var

 FormCnt: Int32;
 UsedDigits : tUsedDigits;

procedure Out_(n,h:Uint32); Begin

 write(n:11,':',h:7);
 inc(FormCnt);
 If FormCnt >= 4 then
 Begin
   FormCnt := 0;
   writeln;
 end;

end;

function DecHexToDec(n:Uint32):UInt32; //convert n as its decimal digits are a hex number //marking used Digits var

 pD : pUint64;
 q,r,pot16 : UInt32;

begin //clear UsedDigits //For q := Low(UsedDigits) to High(UsedDigits) do UsedDigits[q] := 0; //much faster

 pD := @UsedDigits;pD[0]:= 0;pD[1]:= 0;
 result := 0;
 pot16 := 0;
 repeat
   q := n Div 10;
   r := n - 10* q;//n mod 10
   //marked by hex
   UsedDigits[r] := 2;
   result := result+ r shl pot16;
   inc(pot16,4);
   n := q;
 until n = 0;

end;

var

 DecHex,n:Uint32;
 i,q,r,count : Uint32;

Begin

 FormCnt := 0;
 count := 0;
 DecHex := 0;
 repeat
   n := DecHexToDec(DecHex);
   if n > UpperLimit then
     break;
   //check UsedDigits
   i := n;
   repeat
     q := i Div 10;
     r := i - 10* q;
     //if unused digit then break
     if UsedDigits[r] = 0 then
       BREAK;
     //marked by dec
     UsedDigits[r] := 1;
     i := q;
   until i = 0;
   if i = 0 then
   Begin
     repeat
       //was marked only by hex
       if UsedDigits[i]>1 then
         break;
       inc(i);
     until i > 9;
     if i > 9 then
     Begin
       if n< 100*1000 then
         Out_(n,DecHex);
       inc(count);
     end;
   end;
   inc(DecHex);
 until false;
 writeln;
 writeln('count : ',count);

END. </lang>

Output:
TIO.RUN
        0:     0        1:     1        2:     2        3:     3
        4:     4        5:     5        6:     6        7:     7
        8:     8        9:     9       53:    35      371:   173
      913:   391     1040:   410     2080:   820     2339:   923
     4100:  1004     5141:  1415     5412:  1524     5441:  1541
     6182:  1826     8200:  2008     9241:  2419    13593:  3519
    13665:  3561    13969:  3691    16406:  4016    20530:  5032
    26946:  6942    30979:  7903    32803:  8023    33638:  8366
    33840:  8430    33841:  8431    33842:  8432    33843:  8433
    33844:  8434    33845:  8435    33846:  8436    33847:  8437
    33848:  8438    33849:  8439    34883:  8843    37943:  9437
    38931:  9813    38966:  9836    38995:  9853    66310: 10306
    71444: 11714    71497: 11749    71511: 11757    75120: 12570
    75121: 12571    75122: 12572    75123: 12573    75124: 12574
    75125: 12575    75126: 12576    75127: 12577    75128: 12578
    75129: 12579    75621: 12765    86150: 15086    88165: 15865
    91465: 16549    91769: 16679    96617: 17969    98711: 18197
    99481: 18499
count : 69
//1000*1000*1000
  966366598:39999586  966366853:39999685
count : 54558 Real time: 1.666 s

Perl

<lang perl>use strict; no warnings; use feature 'say';

sub eqv { (join , sort split , $_[0]) eq (join , sort split , $_[1]) } say join ' ', grep { eqv $_, sprintf '%x', $_ } 1..100_000;</lang>

Output:
1 2 3 4 5 6 7 8 9 53 371 913 4100 5141 5412 6182 8200 9241 75120 75121 75122 75123 75124 75125 75126 75127 75128 75129 75621 86150 91465 98711 99481

Phix

function handusc(integer n) return unique(sprintf("%x",n))=unique(sprintf("%d",n)) end function
?shorten(filter(tagset(100000,0),handusc),"found",10)
Output:
{0,1,2,3,4,5,6,7,8,9,"...",75128,75129,75621,86150,88165,91465,91769,96617,98711,99481," (69 found)"}

Python

Procedural

<lang python>col = 0 for i in range(100000):

   if set(str(i)) == set(hex(i)[2:]):
       col += 1
       print("{:7}".format(i), end='\n'[:col % 10 == 0])

print()</lang>

Output:
      0      1      2      3      4      5      6      7      8      9
     53    371    913   1040   2080   2339   4100   5141   5412   5441
   6182   8200   9241  13593  13665  13969  16406  20530  26946  30979
  32803  33638  33840  33841  33842  33843  33844  33845  33846  33847
  33848  33849  34883  37943  38931  38966  38995  66310  71444  71497
  71511  75120  75121  75122  75123  75124  75125  75126  75127  75128
  75129  75621  86150  88165  91465  91769  96617  98711  99481

Functional

<lang python>Decimal - Hexadecimal numbers


  1. p :: Int -> Bool

def p(n):

   True if the hex and dec representations
      of n use the same set of digits.
   
   return set(hex(n)[2:]) == set(str(n))


  1. ------------------------- TEST -------------------------
  2. main :: IO ()

def main():

   Matches below 100000
   print(
       table(10)([
           str(x) for x in range(100000)
           if p(x)
       ])
   )


  1. ----------------------- GENERIC ------------------------
  1. 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


  1. table :: Int -> [a] -> String

def table(n):

   A list of values 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)([
               x.rjust(w, ' ') for x in xs
           ])
       )
   return go


  1. MAIN ---

if __name__ == '__main__':

   main()</lang>
Output:
    0     1     2     3     4     5     6     7     8     9
   53   371   913  1040  2080  2339  4100  5141  5412  5441
 6182  8200  9241 13593 13665 13969 16406 20530 26946 30979
32803 33638 33840 33841 33842 33843 33844 33845 33846 33847
33848 33849 34883 37943 38931 38966 38995 66310 71444 71497
71511 75120 75121 75122 75123 75124 75125 75126 75127 75128
75129 75621 86150 88165 91465 91769 96617 98711 99481

Quackery

<lang Quackery> [ 0 swap witheach [ bit | ] ] is ->set ( [ --> s )

 [ 10 base put
   dup  number$ ->set
   16 base replace
   swap number$ ->set
   base release
   = ]                         is dec=hex ( n --> b )
 []
 100000 times
   [ i^ dec=hex if
       [ i^ number$
         nested join ] ]
 60 wrap$</lang>
Output:
0 1 2 3 4 5 6 7 8 9 53 371 913 1040 2080 2339 4100
5141 5412 5441 6182 8200 9241 13593 13665 13969
16406 20530 26946 30979 32803 33638 33840 33841
33842 33843 33844 33845 33846 33847 33848 33849
34883 37943 38931 38966 38995 66310 71444 71497
71511 75120 75121 75122 75123 75124 75125 75126
75127 75128 75129 75621 86150 88165 91465 91769
96617 98711 99481

Raku

Much is left open to interpretation.

Numbers which when expressed in decimal and in hexadecimal are composed of the same digit glyphs. <lang perl6>say (^100000).hyper(:5000batch).grep( { [eqv] ($_, .fmt: '%x').map( *.comb.Bag ) } ).batch(10)».fmt('%5d').join("\n")</lang>

Output:
    0     1     2     3     4     5     6     7     8     9
   53   371   913  4100  5141  5412  6182  8200  9241 75120
75121 75122 75123 75124 75125 75126 75127 75128 75129 75621
86150 91465 98711 99481

Numbers which when expressed in decimal and in hexadecimal are composed from the same digit glyphs. <lang perl6>say (^100000).hyper(:5000batch).grep( { [eqv] ($_, .fmt: '%x').map( *.comb.Set ) } ).batch(10)».fmt('%5d').join("\n")</lang>

Output:
    0     1     2     3     4     5     6     7     8     9
   53   371   913  1040  2080  2339  4100  5141  5412  5441
 6182  8200  9241 13593 13665 13969 16406 20530 26946 30979
32803 33638 33840 33841 33842 33843 33844 33845 33846 33847
33848 33849 34883 37943 38931 38966 38995 66310 71444 71497
71511 75120 75121 75122 75123 75124 75125 75126 75127 75128
75129 75621 86150 88165 91465 91769 96617 98711 99481

REXX

<lang rexx>/*REXX pgm finds integers when shown in decimal and hexadecimal use the same numerals.*/ parse arg n cols . /*obtain optional argument from the CL.*/ if n== | n=="," then n = 100000 /*Not specified? Then use the default.*/ if cols== | cols=="," then cols= 10 /* " " " " " " */ w= 10 /*width of a number in any column. */

                    @hHex= ' decimal integers when displayed in decimal and'      ,
                           "hexadecimal use the same numerals, where  N  < "   commas(n)

say ' index │'center(@hHex, 1 + cols*(w+1) ) /*display the title for the output. */ say '───────┼'center("" , 1 + cols*(w+1), '─') /* " a sep " " " */ dHex= 0; idx= 1 /*initialize # of high hexadecimal nums*/ $= /*list of high hexadecimal #'s (so far)*/

   do j=0  for n;     h= d2x(j)                 /*search for high hexadecimal numbers. */
   if verify(j, h)>0  then iterate              /*Does the decimal and hexadecimal ··· */   /* ◄■■■■■■■■ a filter. */
   if verify(h, j)>0  then iterate              /*     ··· versions use same numerals? */   /* ◄■■■■■■■■ a filter. */
   dHex= dHex + 1                               /*bump number of decimal-hex numbers.  */
   $= $  right(commas(j), w)                    /*add a dec-hexadecimal number──► list.*/
   if dHex // 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 ' commas(dHex) @hHex exit 0 /*stick a fork in it, we're all done. */ /*──────────────────────────────────────────────────────────────────────────────────────*/ commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?</lang>

output   when using the default inputs:
 index │     decimal integers when displayed in decimal and hexadecimal use the same numerals, where  N  <  100,000
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │          0          1          2          3          4          5          6          7          8          9
  11   │         53        371        913      1,040      2,080      2,339      4,100      5,141      5,412      5,441
  21   │      6,182      8,200      9,241     13,593     13,665     13,969     16,406     20,530     26,946     30,979
  31   │     32,803     33,638     33,840     33,841     33,842     33,843     33,844     33,845     33,846     33,847
  41   │     33,848     33,849     34,883     37,943     38,931     38,966     38,995     66,310     71,444     71,497
  51   │     71,511     75,120     75,121     75,122     75,123     75,124     75,125     75,126     75,127     75,128
  61   │     75,129     75,621     86,150     88,165     91,465     91,769     96,617     98,711     99,481
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────

Found  69  decimal integers when displayed in decimal and hexadecimal use the same numerals, where  N  <  100,000

Ring

<lang ring> see "working..." + nl

row = 0 limit = 100000

for n = 0 to limit

   flag1 = 1
   flag2 = 1
   decStr = string(n)
   hexStr = hex(n)
   for m = 1 to len(decStr)
       ind = substr(hexStr,decStr[m])
       if ind < 1
          flag1 = 0
          exit
       ok
   next
   for p = 1 to len(hexStr)
       ind = substr(decStr,hexStr[p])
       if ind < 1
          flag2 = 0
          exit
       ok
   next
   if flag1 = 1 and flag2 = 1
      row = row + 1
      see "" + n + " "
      if row%5 = 0
         see nl
      ok
   ok

next

see nl + "Found " + row + " numbers" + nl see "done..." + nl </lang>

Output:
working...
0 1 2 3 4 
5 6 7 8 9 
53 371 913 1040 2080 
2339 4100 5141 5412 5441 
6182 8200 9241 13593 13665 
13969 16406 20530 26946 30979 
32803 33638 33840 33841 33842 
33843 33844 33845 33846 33847 
33848 33849 34883 37943 38931 
38966 38995 66310 71444 71497 
71511 75120 75121 75122 75123 
75124 75125 75126 75127 75128 
75129 75621 86150 88165 91465 
91769 96617 98711 99481 
Found 69 numbers
done...

Wren

Library: Wren-fmt
Library: Wren-set

<lang ecmascript>import "/fmt" for Conv, Fmt import "/set" for Set

var limit = 1e5 var count = 0 System.print("Numbers under 100,000 which use the same digits in decimal or hex:") for (n in 0...limit) {

   var h = Conv.hex(n)
   var hs = Set.new(h)
   var ns = Set.new(n.toString)
   if (hs == ns) {
       count = count + 1
       Fmt.write("$,6d ", n)
       if (count % 10 == 0) System.print()
   }

} System.print("\n\n%(count) such numbers found.")</lang>

Output:
Numbers under 100,000 which use the same digits in decimal or hex:
     0      1      2      3      4      5      6      7      8      9 
    53    371    913  1,040  2,080  2,339  4,100  5,141  5,412  5,441 
 6,182  8,200  9,241 13,593 13,665 13,969 16,406 20,530 26,946 30,979 
32,803 33,638 33,840 33,841 33,842 33,843 33,844 33,845 33,846 33,847 
33,848 33,849 34,883 37,943 38,931 38,966 38,995 66,310 71,444 71,497 
71,511 75,120 75,121 75,122 75,123 75,124 75,125 75,126 75,127 75,128 
75,129 75,621 86,150 88,165 91,465 91,769 96,617 98,711 99,481 

69 such numbers found.

XPL0

<lang XPL0>func DigitSet(N, D); \Return a bit array containing the set of digits in N divisible by D int N, D; int Set; [Set:= 0; repeat N:= N/D;

       Set:= Set or 1<<rem(0);

until N=0; return Set; ];

int Count, N; [Count:= 0; for N:= 0 to 99999 do

   [if DigitSet(N,10) = DigitSet(N,16) then
       [IntOut(0, N);
       Count:= Count+1;
       if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\);
       ];
   ];

CrLf(0); IntOut(0, Count); Text(0, " such numbers found. ") ]</lang>

Output:
0       1       2       3       4       5       6       7       8       9
53      371     913     1040    2080    2339    4100    5141    5412    5441
6182    8200    9241    13593   13665   13969   16406   20530   26946   30979
32803   33638   33840   33841   33842   33843   33844   33845   33846   33847
33848   33849   34883   37943   38931   38966   38995   66310   71444   71497
71511   75120   75121   75122   75123   75124   75125   75126   75127   75128
75129   75621   86150   88165   91465   91769   96617   98711   99481   
69 such numbers found.