Advertisement
Dianov

For Loop - Lab (04. Even Powers of 2)

Dec 26th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace EvenPowersOf2
  8.  
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int n = int.Parse(Console.ReadLine());
  15.             int num = 2;
  16.             Console.WriteLine(Math.Pow(num, 0));
  17.             for (int i = 1; i <= n; i++)
  18.             {
  19.                 if (i % 2 == 0)
  20.                 {
  21.                     Console.WriteLine(Math.Pow(num, i));
  22.                 }
  23.             }
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement