Advertisement
MARINA_GREBENAROVA

Even_Powers_of_2

Oct 6th, 2021
937
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Even_Powers_of_2
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             //powers = 0 2 4 6 8 10 12...
  12.             //result = 1 4 16...
  13.  
  14.             for (int power = 0; power <= n; power += 2)
  15.             {
  16.                 //formula -> print
  17.                 Console.WriteLine(Math.Pow(2, power));
  18.             }
  19.  
  20.         }
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement