Numbers with same digit set in base 10 and base 16: Difference between revisions

Content added Content deleted
(→‎{{header|Haskell}}: Added a version in Haskell)
Line 530: Line 530:
69 such numbers found.
69 such numbers found.
</pre>
</pre>

=={{header|Haskell}}==
<lang haskell>import qualified Data.Set as S
import Numeric (showHex)

---- NUMBERS WITH THE SAME DIGIT SET IN DECIMAL AND HEX --

sameDigitSet :: (Integral a, Show a) => a -> [(String, String)]
sameDigitSet n =
[ (d, h)
| let d = show n,
let h = showHex n "",
S.fromList h == S.fromList d
]

--------------------------- TEST -------------------------
main = do
print ("decimal", "hex")
mapM_ print $ [0 .. 100000] >>= sameDigitSet</lang>
{{Out}}
<pre>("decimal","hex")
("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")</pre>


=={{header|J}}==
=={{header|J}}==