<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>inamori</author_name>
  <author_url>https://blog.hatena.ne.jp/inamori/</author_url>
  <blog_title>inamori’s diary</blog_title>
  <blog_url>https://inamori.hateblo.jp/</blog_url>
  <categories>
    <anon>Scala</anon>
  </categories>
  <description>Problem 6 val N = 100 val s = (1 to N).sum val s2 = (1 to N).map((n) =&gt; n * n).sum println (s * s - s2) これでもよいですが、fold系を使う方法もあります。 fold系メソッド 自乗和は、 (0 + 1 * 1) + 2 * 2 + ... と計算できます。これは初期値が必要なので前回のreduceLeftでは求められません。reduceLeftを使うと、 (1 + 2 * 2) + 3 * 3 + ... となってしまいます。たまたま同じ答えになってしまうのですが。 foldLeftは次の…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Finamori.hateblo.jp%2Fentry%2F20110525%2Fp1&quot; title=&quot;ScalaでProject Euler（13） - inamori’s diary&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2011-05-25 00:00:00</published>
  <title>ScalaでProject Euler（13）</title>
  <type>rich</type>
  <url>https://inamori.hateblo.jp/entry/20110525/p1</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
