<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>tomomii</author_name>
  <author_url>https://blog.hatena.ne.jp/tomomii/</author_url>
  <blog_title>Words fly away, the written letter remains. </blog_title>
  <blog_url>https://tomomii.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>同じことを何度も繰り返したいときにはループを使い、問題の小さい部分が全体の問題に似ているときに再帰を使います。例えば階乗の計算です。 def factorial num if num &lt; 0 return #負の数の階乗計算不可能 end if num &lt;= 1 1 else num*factorial(num-1) end end puts factorial(4) puts factorial(20) 分解脳がすごく必要ですね。階乗とはつまりどういうことということがわからないとだめ。 moomin:ProgrammingRuby tomomi$ ruby recursion.rb 24 2…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftomomii.hatenablog.com%2Fentry%2F20101127%2Fp2&quot; title=&quot;再帰 (recursion) - Words fly away, the written letter remains. &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>2010-11-27 00:00:00</published>
  <title>再帰 (recursion)</title>
  <type>rich</type>
  <url>https://tomomii.hatenablog.com/entry/20101127/p2</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
