2008-08-01ãã1ã¶æéã®è¨äºä¸è¦§
ããããç¾å®éé¿ã§ããã sumOfDivs x = sum $ filter (\y -> rem x y == 0) [1..(div x 2)] amicables = filter (\n -> let t = sumOfDivs n in n == sumOfDivs t && n /= t) [2..10000] main = print $ sum amicables
決ãã¦æãªããã§ã¯ãªãã import Data.List prime = p [2..] where p (x:xs) = x : p (filter (\y -> rem y x /= 0) xs) factor n = f n prime where f 1 _ = [] f n (p:ps) | rem n p == 0 = p : f (div n p) (p:ps) | otherwise = f n ps finder 4 (x:_) â¦
æ ããªããã¨ã«ããããã¬ã£ã¦ããã¾ã使ã£ããã¨ããªãã使ã£ããã¨ãããã®ã¯ gdb ãããã ãã©ãç¹ã«ä½¿ãæ¹ãè¦ããåªåãããªãã£ãããã¾ã¨ãã«ä½¿ããªããããããã C ãæ¸ããã¨ããªããªã£ã¦ãã¾ã£ããã(æããã°ã©ãã³ã° C# ãèªãã ã¨ãã«ãVisualâ¦
ä»æ¥ã¯ãªã¼ãã³ã½ã¼ã¹ã«ã³ãã¡ã¬ã³ã¹2008 Nagoya ã«åå ãã¦ãããã¨ãã£ã¦ã主ã«èããã®ã¯æ¼ã® Lightning Talk ã ããªãã ãã©ãçºè¡¨ããã id:yoshihiro503 ãã㨠O ããããã¤ãããã¾ã§ããããããããOSC éå¬å´ã®äººããã¤ãããã¾ã§ããã(ããã§è¨â¦
Haskell ã 㨠"(1,2) import Data.List prime = p [2..] where p (x:xs) = x : p (filter (\y -> rem y x /= 0) xs) factor n = f n prime where f 1 _ = [] f n (p:ps) | rem n p == 0 = p : f (div n p) (p:ps) | otherwise = f n ps rad x = product $ nuâ¦
ActionScript ã® map é¢æ°ã¯ãªãã¨å¼æ°ã3ã¤ããã®è¦ç´ ã¨ãã¤ã³ããã¯ã¹ã¨ãé åãã®ãã®ã var x : Array = [1,2,3]; x.map(function(elem:*, idx:int, arr:Array) : Array { ... });
ç´ æ°åãä½ãé¢æ°ã¯ä»ã¾ã§ã«ä½åæ¸ãããããããâ¦ã import Data.List prime = p [2..] where p (x:xs) = x : p (filter (\y -> rem y x /= 0) xs) factor n = f n prime where f 1 _ = [] f n (p:ps) | rem n p == 0 = p : f (div n p) (p:ps) | otherwiseâ¦
Scala ã®ç·´ç¿ã object Problem92 { def step(m : Int) : Int = { var result : Int = 0 var n : Int = m while ( n != 0 ) { result += (n % 10) * (n % 10) n /= 10 } return result } def loop(n: Int) : Boolean = { if ( n==1 ) return false else if (â¦
åæã§ãªãã¨ããªãåé¡ã£ã¦æ°æ¥½ã§ãããã¼ã import Data.Char step 1 = False step 89 = True step n = step $ sum $ map ((^2) . digitToInt) $ show n main = print $ length $ filter step [1..10000000] ./a.out 49.79s user 0.45s system 99% cpu 50.â¦
ãªããªãæéãããã£ã¦ããâ¦ã triangle = [n*(n+1) `div` 2| n <- [1..]] pentagonal = [n*(3*n-1) `div` 2| n <- [1..]] hexagonal = [n*(2*n-1)| n <- [1..]] loop :: [Int] -> [Int] -> [Int] -> [Int] loop (x:xs) (y:ys) (z:zs) | x == y && y == z =â¦
ãªãã ã Haskell ã ã¨ãã¾ããããªãã®ã§ Scala ã§ãå®éã«ã¯ eclipse ãã©ã°ã¤ã³ã« scala ã¢ã¼ããããã®ãç¥ã£ã¦ãªããæ¸ãã¦ã¿ããã£ãã ããªãã§ãããHaskell çããã®ã¾ã¾ç§»æ¤ãã説ãæ¿åã ã¤ãã¬ã¼ã¿ãç¶æ¿ãã¦ã¿ãããããã³ã³ã¹ãã©ã¯ã¿ã®æ¸ãæ¹â¦