Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- public static int Factorial(int numb)
- {
- int res = 1;
- for (int i = numb; i > 1; i--)
- res *= i;
- return res;
- }
- static void Main(string[] args)
- {
- double e = 0.0001;
- //Console.Write(e);
- int m = int.Parse(Console.ReadLine());
- double sum = 1;
- int j = 2;
- int j1 = 4;
- for (int i = 1; i < m; i++)
- {
- sum +=((Math.Cos(Math.Pow(i,2)))) / Factorial(j) -
- (Math.Cos(Math.Pow(i,2))) / Factorial(j1);
- j += 4;
- j1 += 4;
- Console.WriteLine(sum);
- if(Math.Abs(sum) < e)
- {
- Console.Write("exit");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment