Created
August 23, 2019 03:02
-
-
Save longtth/ab39ce33d01f6625d83deeb377027be2 to your computer and use it in GitHub Desktop.
S = 1 + x^2/2! + x^4/4! +...+ x^2n/2n!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace GiaiBaiTap | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| int x = 3; | |
| int n = 4; | |
| Console.WriteLine(TinhS(x,n)); | |
| Console.ReadLine(); | |
| } | |
| static double TinhS(int x, int n) | |
| { | |
| double tmp = 1; | |
| for (int i = 1; i <= n; i++) | |
| { | |
| return tmp += Math.Pow(x, 2 * i) / GiaiThua(2 * i); | |
| } | |
| return tmp; | |
| } | |
| static long GiaiThua(int x) | |
| { | |
| long tmp = 1; | |
| for (int i = 1; i <= x; i++) | |
| { | |
| tmp *= i; | |
| } | |
| return tmp; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment