Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _1._9_Sum_of_Odd_Numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- int sum = 0;
- int n = 0;
- for (int i = 1; i <= number; i++)
- {
- n = 2 * i - 1;
- Console.WriteLine(n);
- sum += n;
- }
- Console.WriteLine($"Sum: {sum}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment