├── Series Patterns ├── Program3.cs ├── Program4.cs ├── Program5.cs ├── Program6.cs ├── Program7.cs ├── Program9.cs ├── Program8.cs ├── Program1.cs └── Program2.cs ├── Wave Patterns ├── Program10.cs ├── Program9.cs ├── Program2.cs ├── Program3.cs ├── Program1.cs ├── Program8.cs ├── Program4.cs ├── Program5.cs ├── Program7.cs └── Program6.cs ├── Spiral Patterns ├── Program4.cs ├── Program1.cs ├── Program2.cs └── Program3.cs └── LICENSE /Series Patterns/Program3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class OddNumbersSeries 4 | { 5 | public static void Main(string[] agrs) 6 | { 7 | int n = 5; //size 8 | 9 | for (int i = 1; i <= n; i++) 10 | { 11 | Console.Write(" " + (2 * i - 1)); 12 | } 13 | Console.ReadKey(true); 14 | } 15 | } 16 | 17 | /* 18 | OUTPUT : 19 | 20 | 1 3 5 7 9 21 | 22 | **/ 23 | -------------------------------------------------------------------------------- /Series Patterns/Program4.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class EvenNumbersSeries 4 | { 5 | public static void Main(string[] agrs) 6 | { 7 | int n = 5; //size 8 | 9 | for (int i = 1; i <= n; i++) 10 | { 11 | Console.Write(" " + (2 * i)); 12 | } 13 | Console.ReadKey(true); 14 | } 15 | } 16 | 17 | /* 18 | OUTPUT : 19 | 20 | 2 4 6 8 10 21 | 22 | **/ 23 | -------------------------------------------------------------------------------- /Series Patterns/Program5.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class SquareNumbersSeries 4 | { 5 | public static void Main(string[] agrs) 6 | { 7 | int n = 5; //size 8 | 9 | for (int i = 1; i <= n; i++) 10 | { 11 | Console.Write(" " + (i * i)); 12 | } 13 | Console.ReadKey(true); 14 | } 15 | } 16 | 17 | /* 18 | OUTPUT : 19 | 20 | 1 4 9 16 25 21 | 22 | **/ 23 | -------------------------------------------------------------------------------- /Series Patterns/Program6.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class CubeNumbersSeries 4 | { 5 | public static void Main(string[] agrs) 6 | { 7 | int n = 5; //size 8 | 9 | for (int i = 1; i <= n; i++) 10 | { 11 | Console.Write(" " + (i * i * i)); 12 | } 13 | Console.ReadKey(true); 14 | } 15 | } 16 | 17 | /* 18 | OUTPUT : 19 | 20 | 1 8 27 64 125 21 | 22 | **/ 23 | -------------------------------------------------------------------------------- /Series Patterns/Program7.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class FibonacciNumbersSeries 4 | { 5 | public static void Main(string[] agrs) 6 | { 7 | int n = 15; //size or upper limit 8 | int a = 0; 9 | int b = 1; 10 | int c = a + b; 11 | 12 | while (c <= n) 13 | { 14 | Console.Write(" " + c); 15 | c = a + b; 16 | a = b; 17 | b = c; 18 | } 19 | Console.ReadKey(true); 20 | } 21 | } 22 | 23 | /* 24 | OUTPUT : 25 | 26 | 1 1 2 3 5 8 13 27 | 28 | **/ 29 | -------------------------------------------------------------------------------- /Series Patterns/Program9.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /* 4 | The sequence which is generated from a pattern of dots which form a triangle is known as Triangular Number Sequence. 5 | */ 6 | 7 | class TriangularNumbersSeries 8 | { 9 | public static void Main(string[] agrs) 10 | { 11 | int n = 5; //size 12 | 13 | for (int i = 1; i <= n; i++) 14 | { 15 | int num = (i * (i + 1)) / 2; 16 | Console.Write(" " + num); 17 | } 18 | Console.ReadKey(true); 19 | } 20 | } 21 | 22 | /* 23 | OUTPUT : 24 | 25 | 1 3 6 10 15 26 | 27 | **/ 28 | -------------------------------------------------------------------------------- /Wave Patterns/Program10.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_10 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int wH = 4; //wave height-> change value to increase or decrease the height of wave 8 | 9 | 10 | int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 | int x = wH - 1; //if cond for printing 14 | 15 | for (int i = 0; i <= wH; i++) 16 | { 17 | for (int j = 0; j < wH * wL * 2; j++) 18 | { 19 | 20 | if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 21 | { 22 | Console.Write("*"); 23 | } 24 | else 25 | { 26 | Console.Write(" "); 27 | } 28 | } 29 | x--; 30 | Console.WriteLine(); 31 | } 32 | Console.ReadKey(true); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Wave Patterns/Program9.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_9 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int wH = 4; //wave height-> change value to increase or decrease the height of wave 8 | 9 | 10 | int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 | int x = wH - 1; //if cond for printing 14 | 15 | 16 | for (int i = 0; i <= wH; i++) 17 | { 18 | for (int j = 0; j < wH * wL * 2; j++) 19 | { 20 | 21 | if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 22 | { 23 | Console.Write("|"); 24 | } 25 | else 26 | { 27 | Console.Write(" "); 28 | } 29 | } 30 | x--; 31 | Console.WriteLine(); 32 | } 33 | Console.ReadKey(true); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Wave Patterns/Program2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_2 4 | { 5 | public static void Main(string[] args) 6 | { 7 | 8 | int waveHeight = 4; //change value to increase or decrease the height of wave 9 | 10 | 11 | int wL = 4; //wave length->change value to increase or decrease the length of wave 12 | 13 | 14 | int wH = waveHeight - 1; //for loop cond. 15 | 16 | int x = wH; //if cond for printing 17 | 18 | 19 | for (int i = 0; i <= wH; i++) 20 | { 21 | for (int j = 0; j <= wH * wL * 2; j++) 22 | { 23 | 24 | if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 25 | { 26 | Console.Write("|"); 27 | } 28 | else 29 | { 30 | Console.Write(" "); 31 | } 32 | } 33 | x--; 34 | Console.WriteLine(); 35 | } 36 | 37 | Console.ReadKey(true); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Wave Patterns/Program3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_3 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int waveHeight = 4; //change value to increase or decrease the height of wave 8 | 9 | 10 | int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 | int wH = waveHeight - 1; //for loop cond. 14 | 15 | int x = wH; //if cond for printing 16 | 17 | 18 | for (int i = 0; i <= wH; i++) 19 | { 20 | for (int j = 0; j <= wH * wL * 2; j++) 21 | { 22 | 23 | if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 24 | { 25 | Console.Write("{0:D2}", j); 26 | } 27 | else 28 | { 29 | Console.Write(" "); 30 | } 31 | } 32 | x--; 33 | Console.WriteLine(); 34 | } 35 | 36 | Console.ReadKey(true); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Spiral Patterns/Program4.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class SpiralNumberPattern2 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int i = 1; 8 | int rows = 10; 9 | int k = 1; 10 | int x = 1; 11 | 12 | for (x = 1; x <= rows * 2; x += 2) 13 | { 14 | if (k % 2 == 1) 15 | { 16 | Console.Write("{0:D2} {1:D2} {2:D2} {3:D2} ", i, (i + 1), (i + 2), (i + 3)); 17 | k++; 18 | i += 4; 19 | } 20 | else 21 | { 22 | Console.Write("{0:D2} {1:D2} {2:D2} {3:D2} ", (i + 3), (i + 2), (i + 1), i); 23 | k++; 24 | i += 4; 25 | } 26 | Console.WriteLine(); 27 | } 28 | Console.ReadKey(true); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Wave Patterns/Program1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_1 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int waveHeight = 4; //change value to increase or decrease the height of wave 8 | 9 | 10 | int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 | int wH = waveHeight - 1; //for loop cond. 14 | 15 | int x = wH; //if cond for printing 16 | 17 | 18 | for (int i = 0; i <= wH; i++) 19 | { 20 | for (int j = 0; j <= wH * wL * 2; j++) 21 | { 22 | 23 | if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 24 | { 25 | Console.Write("*"); 26 | } 27 | else 28 | { 29 | Console.Write(" "); 30 | } 31 | } 32 | x--; 33 | Console.WriteLine(); 34 | } 35 | Console.ReadKey(true); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Wave Patterns/Program8.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_8 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int wH = 4; //wave height-> change value to increase or decrease the height of wave 8 | 9 | 10 | int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 | int x = wH - 1; //if cond for printing 14 | 15 | 16 | for (int i = 0; i <= wH; i++) 17 | { 18 | for (int j = 0; j < wH * wL * 2; j++) 19 | { 20 | 21 | if (j % (wH * 2) == x) 22 | { 23 | Console.Write("/"); 24 | } 25 | else if (j % (wH * 2) == wH + i) 26 | { 27 | Console.Write("\\"); 28 | } 29 | else 30 | { 31 | Console.Write(" "); 32 | } 33 | } 34 | x--; 35 | Console.WriteLine(); 36 | } 37 | 38 | Console.ReadKey(true); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Wave Patterns/Program4.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_4 4 | { 5 |  public static void Main(string[] args) 6 |  { 7 |   int waveHeight = 4; //change value to increase or decrease the height of wave 8 | 9 | 10 |   int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 |   int wH = waveHeight - 1; //for loop cond. 14 | 15 |   int x = wH; //if cond for printing 16 |   int cp; //print char 17 | 18 | 19 |   for (int i = 0; i <= wH; i++) 20 |   { 21 |    cp = 'A'; // set print char. 22 | 23 |    for (int j = 0; j <= wH * wL * 2; j++) 24 |    { 25 |     if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 26 |     { 27 |      Console.Write((char)cp); 28 |     } 29 |     else 30 |     { 31 |      Console.Write(" "); 32 |     } 33 | 34 |     cp++; // increment print char 35 | 36 |     /reset print char to 'A'/ 37 |     if (cp > 'Z') 38 |     { 39 |      cp = cp - 26; 40 |     } 41 | 42 |    } 43 |    x--; 44 |    Console.WriteLine(); 45 |   } 46 |   Console.ReadKey(true); 47 | 48 |  } 49 | } 50 | -------------------------------------------------------------------------------- /Wave Patterns/Program5.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_5 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int waveHeight = 4; //change value to increase or decrease the height of wave 8 | 9 | 10 | int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 | int wH = waveHeight - 1; //for loop cond. 14 | 15 | int x = wH; //if cond for printing 16 | int cp; //print char 17 | 18 | 19 | for (int i = 0; i <= wH; i++) 20 | { 21 | cp = 'a'; // set print char. 22 | 23 | for (int j = 0; j <= wH * wL * 2; j++) 24 | { 25 | if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 26 | { 27 | Console.Write((char)cp); 28 | } 29 | else 30 | { 31 | Console.Write(" "); 32 | } 33 | 34 | cp++; // increment print char 35 | 36 | /reset print char to 'a'/ 37 | if (cp > 'z') 38 | { 39 | cp = cp - 26; 40 | } 41 | 42 | } 43 | x--; 44 | Console.WriteLine(); 45 | } 46 | Console.ReadKey(true); 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Wave Patterns/Program7.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_7 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int waveHeight = 4; //change value to increase or decrease the height of wave 8 | 9 | 10 | int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 | int wH = waveHeight - 1; //for loop cond. 14 | 15 | int x = wH; //if cond for printing 16 | int cp; //print char 17 | 18 | 19 | for (int i = 0; i <= wH; i++) 20 | { 21 | cp = 'z'; // set print char. 22 | 23 | for (int j = 0; j <= wH * wL * 2; j++) 24 | { 25 | if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 26 | { 27 | Console.Write((char)cp); 28 | } 29 | else 30 | { 31 | Console.Write(" "); 32 | } 33 | 34 | cp--; // decrement print char 35 | 36 | /reset print char to 'z'/ 37 | if (cp < 'a') 38 | { 39 | cp = cp + 26; 40 | } 41 | 42 | } 43 | x--; 44 | Console.WriteLine(); 45 | } 46 | 47 | Console.ReadKey(true); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Series Patterns/Program8.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /* 4 | * In this program, we print the series of prime numbers up to 'n'. 5 | * First we check each number (1 to n) for prime number. 6 | * If the number is prime we print it. 7 | * 8 | **/ 9 | 10 | class PrimeNumbersSeries 11 | { 12 | public static void Main(string[] agrs) 13 | { 14 | int n = 10; //size 15 | int num = 1, count = 0; 16 | 17 | 18 | while (num <= n) 19 | { 20 | for (int i = 1; i <= num; i++) 21 | { 22 | if (num % i == 0) 23 | { 24 | count++; 25 | } 26 | } 27 | if (count == 2) // true if number is prime 28 | { 29 | Console.Write(" " + num); 30 | } 31 | 32 | count = 0; // reset count 33 | 34 | num++; // for checking next num 35 | } 36 | Console.ReadKey(true); 37 | } 38 | } 39 | 40 | /* 41 | OUTPUT : 42 | 43 | 2 3 5 7 44 | 45 | **/ 46 | -------------------------------------------------------------------------------- /Wave Patterns/Program6.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Wave_6 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int waveHeight = 4; //change value to increase or decrease the height of wave 8 | 9 | 10 | int wL = 4; //wave length->change value to increase or decrease the length of wave 11 | 12 | 13 | int wH = waveHeight - 1; //for loop cond. 14 | 15 | int x = wH; //if cond for printing 16 | int cp; //print char 17 | 18 | 19 | for (int i = 0; i <= wH; i++) 20 | { 21 | cp = 'Z'; // set print char. 22 | 23 | for (int j = 0; j <= wH * wL * 2; j++) 24 | { 25 | if (j % (wH * 2) == x || j % (wH * 2) == wH + i) 26 | { 27 | Console.Write((char)cp); 28 | } 29 | else 30 | { 31 | Console.Write(" "); 32 | } 33 | 34 | cp--; // decrement print char 35 | 36 | /reset print char to 'Z'/ 37 | if (cp < 'A') 38 | { 39 | cp = cp + 26; 40 | } 41 | 42 | } 43 | x--; 44 | Console.WriteLine(); 45 | } 46 | 47 | Console.ReadKey(true); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 PatternHouse 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Series Patterns/Program1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /* 4 | If a sequence of values follows a pattern of adding a fixed amount from one term to the next, it is referred to as an arithmetic sequence. 5 | The number added to each term is constant is called as the common difference, d. 6 | 7 | e.g. 8 | 9 | 1, 4, 7, 10, 13, 16, ... 10 | 11 | An arithmetic sequence starts with term(a) 1 and having common difference (d) of 3. 12 | 13 | */ 14 | 15 | class ArithmeticSequence 16 | { 17 | public static void Main(string[] args) 18 | { 19 | int n = 5; // limit 20 | int d = 3; //common difference 21 | int a = 2; // terms 22 | 23 | /* 24 | (If you want to take input from user, you may use this code) 25 | 26 | Console.WriteLine("Enter A (first term) : "); 27 | a= Convert.ToInt32(Console.ReadLine()); 28 | 29 | Console.WriteLine("Enter N (limit) : "); 30 | n= Convert.ToInt32(Console.ReadLine()); 31 | 32 | Console.WriteLine("Enter D (common difference) : "); 33 | d= Convert.ToInt32(Console.ReadLine()); 34 | */ 35 | 36 | for (int i = 1; i <= n; i++) 37 | { 38 | Console.Write(" " + a); 39 | a = a + d; // adding diff. with term 40 | } 41 | Console.ReadKey(true); 42 | 43 | } // end of main() 44 | } // end of class 45 | 46 | /* 47 | OUTPUT : 48 | 49 | 2 5 8 11 14 50 | 51 | */ 52 | -------------------------------------------------------------------------------- /Spiral Patterns/Program1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class SpiralNumberPattern 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int n = 5; // change to change size 8 | int[,] a = new int[5, 5]; 9 | int i,j; 10 | int ot; 11 | 12 | int x = 0; 13 | int y = 0; 14 | int z = 1; 15 | 16 | for (ot = 0; ot <= n / 2; ot++) 17 | { 18 | if (ot == n / 2) 19 | { 20 | z--; 21 | } 22 | for (j = y; j < n - y; j++) 23 | { 24 | a[x,j] = z; 25 | z++; 26 | } 27 | for (i = x + 1; i < n - x - 1; i++) 28 | { 29 | a[i,n-y-1] = z; 30 | z++; 31 | } 32 | for (j = n - y - 1; j >= y; j--) 33 | { 34 | a[n-x-1,j] = z; 35 | z++; 36 | } 37 | for (i = n - x - 2; i > x; i--) 38 | { 39 | a[i,y] = z; 40 | z++; 41 | } 42 | x++; 43 | y++; 44 | } 45 | 46 | for (i = 0; i < n; i++) 47 | { 48 | for (j = 0; j < n; j++) 49 | { 50 | Console.Write(" {0:D2}", a[i,j]); 51 | } 52 | Console.WriteLine(); 53 | } 54 | Console.ReadKey(true); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Spiral Patterns/Program2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class SpiralNumberRevPattern 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int n = 5; // change to change size 8 | int[,] a = new int[5, 5]; 9 | int i,j; 10 | int ot; 11 | 12 | int x = 0; 13 | int y = 0; 14 | int z = 25; 15 | 16 | for (ot = 0; ot <= n / 2; ot++) 17 | { 18 | if (ot == n / 2) 19 | { 20 | z++; 21 | } 22 | for (j = y; j < n - y; j++) 23 | { 24 | a[x,j] = z; 25 | z--; 26 | } 27 | for (i = x + 1; i < n - x - 1; i++) 28 | { 29 | a[i,n-y-1] = z; 30 | z--; 31 | } 32 | for (j = n - y - 1; j >= y; j--) 33 | { 34 | a[n-x-1,j] = z; 35 | z--; 36 | } 37 | for (i = n - x - 2; i > x; i--) 38 | { 39 | a[i,y] = z; 40 | z--; 41 | } 42 | x++; 43 | y++; 44 | } 45 | 46 | for (i = 0; i < n; i++) 47 | { 48 | for (j = 0; j < n; j++) 49 | { 50 | Console.Write(" {0:D2}", a[i,j]); 51 | } 52 | Console.WriteLine(); 53 | } 54 | Console.ReadKey(true); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Series Patterns/Program2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /* 4 | If a sequence of values follows a pattern of multiplying a fixed amount times each term to arrive at the following term, it is referred to as a geometric sequence. 5 | The number multiplied each time is constant and is called as the common ratio, r. 6 | e.g. 7 | 8 | 2, 6, 18, 54, ... 9 | 10 | An geometric sequence starts with term(a) 2 and having common ratio (r) of 3. 11 | 12 | */ 13 | 14 | class GeometricSequence 15 | { 16 | public static void Main(string[] args) 17 | { 18 | int n = 5; // limit 19 | int r = 2; //common ratio 20 | int a = 5; // terms 21 | int sum = 0; // sum of the series 22 | 23 | /* 24 | (If you want to take input from user, you may use this code) 25 | 26 | Console.WriteLine("Enter A (first term) : "); 27 | a= Convert.ToInt32(Console.ReadLine()); 28 | 29 | Console.WriteLine("Enter N (limit) : "); 30 | n= Convert.ToInt32(Console.ReadLine()); 31 | 32 | Console.Write("Enter R (common ratio) : "); 33 | r= Convert.ToInt32(Console.ReadLine()); 34 | */ 35 | 36 | for (int i = 1; i <= n; i++) 37 | { 38 | Console.Write(" " + a); 39 | a = a * r; // multiplying diff. with term 40 | } 41 | 42 | Console.ReadKey(true); 43 | } // end of main() 44 | } // end of class 45 | 46 | /* 47 | OUTPUT : 48 | 49 | 5 10 20 40 80 50 | */ 51 | -------------------------------------------------------------------------------- /Spiral Patterns/Program3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class SpiralCharPattern 4 | { 5 | public static void Main(string[] args) 6 | { 7 | int n = 8; // change to change size 8 | int[,] a = new int[8, 8]; 9 | int i,j; 10 | int ot; 11 | 12 | int x = 0,y = 0,z = 0; 13 | 14 | for (ot = 0; ot <= n / 2; ot++) 15 | { 16 | if (ot == n / 2) 17 | { 18 | z--; 19 | } 20 | for (j = y; j < n - y; j++) 21 | { 22 | a[x,j] = z; 23 | z++; 24 | } 25 | for (i = x + 1; i < n - x - 1; i++) 26 | { 27 | a[i,n-y-1] = z; 28 | z++; 29 | } 30 | for (j = n - y - 1; j >= y; j--) 31 | { 32 | a[n-x-1,j] = z; 33 | z++; 34 | } 35 | for (i = n - x - 2; i > x; i--) 36 | { 37 | a[i,y] = z; 38 | z++; 39 | } 40 | x++; 41 | y++; 42 | } 43 | 44 | for (i = 0; i < n; i++) 45 | { 46 | for (j = 0; j < n; j++) 47 | { 48 | if (a[i,j] >= 26) 49 | { 50 | a[i,j] %= 26; // reset print char to A 51 | } 52 | 53 | Console.Write((char)(a[i,j] + 65) + " "); 54 | } 55 | Console.WriteLine(); 56 | } 57 | Console.ReadKey(true); 58 | } 59 | } --------------------------------------------------------------------------------