{"height":"190","provider_name":"Hatena Blog","url":"https://inamori.hateblo.jp/entry/20110525/p1","published":"2011-05-25 00:00:00","width":"100%","author_url":"https://blog.hatena.ne.jp/inamori/","author_name":"inamori","categories":["Scala"],"blog_url":"https://inamori.hateblo.jp/","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Finamori.hateblo.jp%2Fentry%2F20110525%2Fp1\" title=\"Scala\u3067Project Euler\uff0813\uff09 - inamori\u2019s diary\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","version":"1.0","description":"Problem 6 val N = 100 val s = (1 to N).sum val s2 = (1 to N).map((n) => n * n).sum println (s * s - s2) \u3053\u308c\u3067\u3082\u3088\u3044\u3067\u3059\u304c\u3001fold\u7cfb\u3092\u4f7f\u3046\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u3002 fold\u7cfb\u30e1\u30bd\u30c3\u30c9 \u81ea\u4e57\u548c\u306f\u3001 (0 + 1 * 1) + 2 * 2 + ... \u3068\u8a08\u7b97\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306f\u521d\u671f\u5024\u304c\u5fc5\u8981\u306a\u306e\u3067\u524d\u56de\u306ereduceLeft\u3067\u306f\u6c42\u3081\u3089\u308c\u307e\u305b\u3093\u3002reduceLeft\u3092\u4f7f\u3046\u3068\u3001 (1 + 2 * 2) + 3 * 3 + ... \u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u305f\u307e\u305f\u307e\u540c\u3058\u7b54\u3048\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3059\u304c\u3002 foldLeft\u306f\u6b21\u306e\u2026","title":"Scala\u3067Project Euler\uff0813\uff09","image_url":null,"provider_url":"https://hatena.blog","blog_title":"inamori\u2019s diary","type":"rich"}