anizko

02. Sequence 2k+1

Apr 4th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Sequence_2k_1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int k = 1;
  11.  
  12.             while(k<=n)
  13.             {
  14.                
  15.                 Console.WriteLine(k);
  16.                 k = 2 * k + 1;
  17.  
  18.             }
  19.                   }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment