Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FileDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] lines = File.ReadAllLines("NUMBERS.TXT");
- foreach (var item in lines)
- {
- try
- {
- double num = double.Parse(item);
- Console.WriteLine(calc(num));
- }
- catch (Exception)
- {
- Console.WriteLine("Error in line: {0}",item);
- }
- }
- }
- public static double calc(double x)
- {
- double s = 0;
- for (int i = 1; i <= 50; i++)
- s += x / (i * i * i);
- return s;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement