Sub-unit squares: Difference between revisions

no edit summary
m (→‎{{header|Phix}}: remark re matching A061844, added a commented-out test for that.)
No edit summary
Line 151:
</pre>
 
=={{header|Haskell}}==
<syntaxhighlight lang=haskell>
import Data.Char ( digitToInt , intToDigit )
 
isSquareNumber :: Int -> Bool
isSquareNumber n = root * root == n
where
root :: Int
root = floor $ sqrt $ fromIntegral n
 
isSubunitSquare :: Int -> Bool
isSubunitSquare n
|elem '0' numstr = False
|otherwise = isSquareNumber n && isSquareNumber subunitnum
where
numstr :: String
numstr = show n
subunitnum :: Int
subunitnum = read $ map ( intToDigit . pred ) $ map digitToInt numstr
 
solution :: [Int]
solution = take 7 $ filter isSubunitSquare [1,2..]</syntaxhighlight>
{{out}}
<pre>
[1,36,3136,24336,118336,126736,5973136]
</pre>
 
=={{header|J}}==
262

edits