C#程序设计(十四)----计算数列的极限值

来源:互联网 发布:网络信息安全三级等保 编辑:程序博客网 时间:2024/05/18 18:46
* 程序的版权和版本声明部分
* Copyright (c) 2012, 烟台大学计算机学院学生
* All rights reserved.

* 作 者: 刘镇
* 完成日期: 2012 年 10 月 27 日
* 版 本 号: 3.014

* 对任务及求解方法的描述部分

* 问题描述:数列a的各项表达式为:a1= ,a2= ,a3= ,…。编写控制台应用程序,计算数列的极限值(n=1000)。

 

*代码部分:

 

 

 

Sequence.cs:

 

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace MySequence{    class Sequence    {        public double limit(int num)        {            double S = 0;            for (int i = 1; i <= num; i++)            {                S += 2;                S = Math.Sqrt(S);            }            return S;        }    }}


 

 

测试类:

 

 

 

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace MySequence{    class Program    {        static void Main(string[] args)        {            Sequence s = new Sequence();            Console.WriteLine("a1000 = " + s.limit(1000));            Console.ReadKey();        }    }}


 

 

测试结果: