ONLY DO WHAT ONLY YOU CAN DO

こけたら立ちなはれ 立ったら歩きなはれ

2013-02-05から1日間の記事一覧

Scala で Project Euler Problem 21

scala> def get_prime_factor(map:collection.mutable.Map[Long, Long], n: Long, factor: Long = 2) { | if (n >= factor) { | if (n % factor != 0 ) | get_prime_factor(map, n, factor + 1) | else { | if (map.contains(factor)) | map(factor) += 1 | …

F# で Project Euler Problem 21

> let mutable map:Map<int, int> = Map.empty;; val mutable map : Map<int,int> = map [] > let rec get_prime_factor (map:Map<int, int> byref) (n:int) (factor: int) = - if n >= factor then - if n % factor <> 0 then - get_prime_factor &map n (factor + 1) - else - if Map.co</int,></int,int></int,>…

Project Euler Problem 21

10000未満の友愛数の和を求めよhttp://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2021 を n の真の約数の和と定義する. (真の約数とは n 以外の約数のことである. ) もし, かつ (a ≠ b のとき) を満たすとき, a と b は友愛数(親和数)…