๐Ÿ“ฆ malash / codewars-solutions

๐Ÿ“„ build-a-pile-of-cubes.hs ยท 11 lines
1
2
3
4
5
6
7
8
9
10
11module Codewars.Kata.PileOfCubes where

findNb :: Integer -> Integer

findNb m
    | div (root * (root + 1)) 2 ^ 2 == m = root
    | otherwise = -1
    where
        intSqrt = floor . sqrt . fromIntegral
        root = intSqrt (intSqrt m * 2)