Numbers with same digit set in base 10 and base 16: Difference between revisions
Content deleted Content added
Not a robot (talk | contribs) Add APL |
Catskill549 (talk | contribs) added AWK |
||
Line 98: | Line 98: | ||
75123 75124 75125 75126 75127 75128 75129 75621 86150 88165 91465 |
75123 75124 75125 75126 75127 75128 75129 75621 86150 88165 91465 |
||
91769 96617 98711 99481</pre> |
91769 96617 98711 99481</pre> |
||
=={{header|AWK}}== |
|||
<lang AWK> |
|||
# 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> |
|||
{{out}} |
|||
<pre> |
|||
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 |
|||
</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |