<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DreamMX Weblogs &#187; Programing</title>
	<atom:link href="http://blog.dreammx.com/tag/programing/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.dreammx.com</link>
	<description>Team Blog</description>
	<lastBuildDate>Sun, 22 Mar 2009 19:07:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use recursion to achieve Fibonacci numbers</title>
		<link>http://blog.dreammx.com/web-development/dotnet/c-sharp/use-recursion-to-achieve-fibonacci-numbers.html</link>
		<comments>http://blog.dreammx.com/web-development/dotnet/c-sharp/use-recursion-to-achieve-fibonacci-numbers.html#comments</comments>
		<pubDate>Wed, 21 Jan 2009 03:08:02 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://blog.dreammx.com/?p=59</guid>
		<description><![CDATA[查看本文的中文版，请点击这里。
Last article illustrated how to use the recursion to achieve factorial calculation by a simple example, and this article will show another classic application of recursion &#8211; Fibonacci numbers.
Fibonacci numbers refers to such an infinite numbers: 1, 1, 2, 3, 5, 8, etc. Except the first two numbers, each number is the sum of the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>查看本文的中文版，请点击<a href="http://liyang80s.com/2009/01/21/fibonacci%e6%95%b0%e5%88%97%e7%9a%84%e9%80%92%e5%bd%92%e5%ae%9e%e7%8e%b0/" target="blank">这里</a>。</strong></p>
<p><a href="http://blog.dreammx.com/wake/web-development/dotnet/c-sharp/use-recursion-to-achieve-factorial-calculation" target="blank">Last article</a> illustrated how to use the recursion to achieve factorial calculation by a simple example, and this article will show another classic application of recursion &#8211; Fibonacci numbers.</p>
<p>Fibonacci numbers refers to such an infinite numbers: 1, 1, 2, 3, 5, 8, etc. Except the first two numbers, each number is the sum of the two preceding numbers.</p>
<p>Since the Fibonacci numbers is defined by recurrence relation, then we can easily use recursion to achieve its calculation.</p>
<p>As the calculation of factorial, the bigger of the numerical calculation, the more times of recursion, and the number of redundant recursion will growth in a  redundant geometric way, the efficiency of program will also be lower and lower (you can modify the program, personally test it). So you need according to the actual situation, and make a decision between readability and efficiency.</p>
<p>Example: Print 10 Fibonacci numbers. Use recursion to achieve it.</p>
<p>Code:</p>
<pre lang="csharp" line="1">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fibonacci
{
    class Program
    {
        public long Fibonacci(int n)
        {
            if (n > 0 &#038;&#038; (n == 1 || n == 2))
            {
                return 1;
            }
            else
            {
                return Fibonacci(n - 1) + Fibonacci(n - 2);
            }
        }

        static void Main(string[] args)
        {
            Program p = new Program();
            for (int i = 1; i < 11; i++)
            {
                Console.Write(p.Fibonacci(i));
            }
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.dreammx.com/web-development/dotnet/c-sharp/use-recursion-to-achieve-fibonacci-numbers.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Use recursion to achieve factorial calculation</title>
		<link>http://blog.dreammx.com/web-development/dotnet/c-sharp/use-recursion-to-achieve-factorial-calculation.html</link>
		<comments>http://blog.dreammx.com/web-development/dotnet/c-sharp/use-recursion-to-achieve-factorial-calculation.html#comments</comments>
		<pubDate>Tue, 20 Jan 2009 05:24:53 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://blog.dreammx.com/?p=57</guid>
		<description><![CDATA[查看本文的中文版，请点击这里。
According to the characteristics of factorial calculation, using recursion to achieve it is very convenient.
Note that recursion is a kind of low efficiency algorithm, especially when calculate with larger operations, so give careful consideration to the circumstances in deciding whether to use it.
This is a example of algorithm I wrote when learning C# programming language.
Example: [...]]]></description>
			<content:encoded><![CDATA[<p><strong>查看本文的中文版，请点击<a href="http://liyang80s.com/2009/01/19/%e9%80%92%e5%bd%92%e8%b0%83%e7%94%a8%e5%ae%9e%e7%8e%b0%e9%98%b6%e4%b9%98%e8%ae%a1%e7%ae%97" target="blank">这里</a>。</strong></p>
<p>According to the characteristics of factorial calculation, using recursion to achieve it is very convenient.</p>
<p>Note that recursion is a kind of low efficiency algorithm, especially when calculate with larger operations, so give careful consideration to the circumstances in deciding whether to use it.</p>
<p>This is a example of algorithm I wrote when learning C# programming language.</p>
<p>Example: Calculate 1! + 2! + &#8230; + 10! and print out the results. Use recursion to achieve it.</p>
<p>Code:</p>
<pre lang="csharp" line="1">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Factorial
{
    class Program
    {
        public long Factorial(int n)
        {
            if (n == 0 || n == 1)
            {
                return 1;
            }
            else
            {
                return n * Factorial(n - 1);
            }
        }

        static void Main(string[] args)
        {
            Program p = new Program();
            long sum = 0;
            for (int i = 1; i < 11; i++)
            {
                sum += p.Factorial(i);
            }
            Console.WriteLine("1! + 2! + ... + 10! = " + sum);
        }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.dreammx.com/web-development/dotnet/c-sharp/use-recursion-to-achieve-factorial-calculation.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

