"Program to find last two digits of 2 ^ n | C # code to find last 2 digits of 2 ^ n ; Find the first digit ; Get the last digit from the number ; Remove last digit from number ; Get the last digit from the number ( last second of num ) ; Take last digit to ten 's position i.e.  last second digit ; Add the value of ones and tens to make it complete 2 digit number ; return the first digit ; Driver code ; pow function used"
Solution in C#:

using System ; class GFG { static long LastTwoDigit ( long num ) { long one = num % 10 ; num /= 10 ; long tens = num % 10 ; tens *= 10 ; num = tens + one ; return num ; } public static void Main ( String [ ] args ) { int n = 10 ; long num = 1 ; num = ( long ) Math . Pow ( 2 , n ) ; Console . WriteLine ( " Last ▁ 2 ▁ digits ▁ of ▁ 2 ^ 10 ▁ = ▁ " + LastTwoDigit ( num ) ) ; } }


"Program to find last two digits of 2 ^ n | C # code to find last 2 digits of 2 ^ n ; Iterative Function to calculate ( x ^ y ) % p in O ( log y ) ; x = x % p ; Update x if it is more than or equal to p ; If y is odd , multiply x with result ; y must be even now y = y >> 1 ; y = y / 2 ; C # function to calculate number of digits in x ; C # function to print last 2 digits of 2 ^ n ; Generating 10 ^ 2 ; Calling modular exponentiation ; Printing leftmost zeros . Since ( 2 ^ n ) % 2 can have digits less then 2. In that case we need to print zeros ; If temp is not zero then print temp If temp is zero then already printed ; Driver Code"
Solution in C#:

using System ; class GFG { static int power ( long x , long y , long p ) { while ( y > 0 ) { long r = y & 1 ; if ( r == 1 ) res = ( res * ( int ) x ) % ( int ) p ; x = ( x * x ) % p ; } return res ; } static int numberOfDigits ( int x ) { int i = 0 ; while ( x != 0 ) { x /= 10 ; i ++ ; } return i ; } static void LastTwoDigit ( int n ) { Console . Write ( " Last ▁ " + 2 + " ▁ digits ▁ of ▁ " + 2 + " ^ " ) ; Console . Write ( n + " ▁ = ▁ " ) ; int temp = 1 ; for ( int i = 1 ; i <= 2 ; i ++ ) temp *= 10 ; temp = power ( 2 , n , temp ) ; for ( int i = 0 ; i < ( 2 - numberOfDigits ( temp ) ) ; i ++ ) Console . Write ( 0 + " ▁ " ) ; if ( temp != 0 ) Console . Write ( temp ) ; } public static void Main ( ) { int n = 72 ; LastTwoDigit ( n ) ; } }


"Program to find line passing through 2 Points | C # Implementation to find the line passing through two points ; This pair is used to store the X and Y coordinate of a point respectively ; Function to find the line given two points ; Driver code"
Solution in C#:

using System ; class GFG { public class Pair { public int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void lineFromPoints ( Pair P , Pair Q ) { int a = Q . second - P . second ; int b = P . first - Q . first ; int c = a * ( P . first ) + b * ( P . second ) ; if ( b < 0 ) { Console . WriteLine ( " The ▁ line ▁ passing ▁ through ▁ points ▁ P ▁ and ▁ Q ▁ is : ▁ " + a + " x ▁ - ▁ " + b + " y ▁ = ▁ " + c ) ; } else { Console . WriteLine ( " The ▁ line ▁ passing ▁ through ▁ points ▁ P ▁ and ▁ Q ▁ is : ▁ " + a + " x ▁ + ▁ " + b + " y ▁ = ▁ " + c ) ; } } public static void Main ( String [ ] args ) { Pair P = new Pair ( 3 , 2 ) ; Pair Q = new Pair ( 2 , 6 ) ; lineFromPoints ( P , Q ) ; } }


"Program to find minimum number of lectures to attend to maintain 75 % | C # Program to find minimum number of lectures to attend to maintain 75 % attendance ; Method to compute minimum lecture ; Formula to compute ; Driver Code"
Solution in C#:

using System ; class GFG { static int minimumLectures ( int m , int n ) { int ans = 0 ; if ( n < ( int ) Math . Ceiling ( 0.75 * m ) ) ans = ( int ) Math . Ceiling ( ( ( 0.75 * m ) - n ) / 0.25 ) ; else ans = 0 ; return ans ; } public static void Main ( ) { int M = 9 , N = 1 ; Console . WriteLine ( minimumLectures ( M , N ) ) ; } }


"Program to find nth term of the series 1 4 15 24 45 60 92 | C # implementation of the above approach ; function to calculate nth term of the series ; variable nth will store the nth term of series ; if n is even ; if n is odd ; return nth term ; Driver code"
Solution in C#:

using System ; class GFG { static long nthTerm ( long n ) { long nth ; if ( n % 2 == 0 ) nth = 2 * ( ( n * n ) - n ) ; else nth = ( 2 * n * n ) - n ; return nth ; } public static void Main ( ) { long n ; n = 5 ; Console . WriteLine ( nthTerm ( n ) ) ; n = 25 ; Console . WriteLine ( nthTerm ( n ) ) ; n = 25000000 ; Console . WriteLine ( nthTerm ( n ) ) ; n = 250000007 ; Console . WriteLine ( nthTerm ( n ) ) ; } }


"Program to find number of solutions in Quadratic Equation | C # Program to find the solutions of specified equations ; Method to check for solutions of equations ; If the expression is greater than 0 , then 2 solutions ; If the expression is equal to 0 , then 2 solutions ; Else no solutions ; Driver Code"
Solution in C#:

using System ; class GFG { static void checkSolution ( int a , int b , int c ) { if ( ( ( b * b ) - ( 4 * a * c ) ) > 0 ) Console . WriteLine ( "2 ▁ solutions " ) ; else if ( ( ( b * b ) - ( 4 * a * c ) ) == 0 ) Console . WriteLine ( "1 ▁ solution " ) ; else Console . WriteLine ( " No ▁ solutions " ) ; } public static void Main ( ) { int a = 2 , b = 5 , c = 2 ; checkSolution ( a , b , c ) ; } }


"Program to find remainder when large number is divided by 11 | C # implementation to find remainder when a large number is divided by 11 ; Function to return remainder ; len is variable to store the length of number string . ; loop that find remainder ; Driver code"
Solution in C#:

using System ; class GFG { static int remainder ( string str ) { int len = str . Length ; int num , rem = 0 ; for ( int i = 0 ; i < len ; i ++ ) { num = rem * 10 + ( str [ i ] - '0' ) ; rem = num % 11 ; } return rem ; } public static void Main ( ) { string str = "3435346456547566345436457867978" ; Console . WriteLine ( remainder ( str ) ) ; } }


"Program to find remainder when large number is divided by r | C # implementation to find Remainder when a large Number is divided by R ; Function to Return Remainder ; len is variable to store the length of Number string . ; loop that find Remainder ; Return the remainder ; Driver code ; Get the large number as string ; Get the divisor R ; Find and print the remainder"
Solution in C#:

using System ; class GFG { static int Remainder ( String str , int R ) { int len = str . Length ; int Num , Rem = 0 ; for ( int i = 0 ; i < len ; i ++ ) { Num = Rem * 10 + ( str [ i ] - '0' ) ; Rem = Num % R ; } return Rem ; } public static void Main ( ) { String str = "13589234356546756" ; int R = 13 ; Console . WriteLine ( Remainder ( str , R ) ) ; } }


"Program to find remainder without using modulo or % operator | C # implementation of the approach ; Function to return num % divisor without using % ( modulo ) operator ; While divisor is smaller than n , keep subtracting it from num ; Driver code"
Solution in C#:

using System ; class GFG { static int getRemainder ( int num , int divisor ) { while ( num >= divisor ) num -= divisor ; return num ; } public static void Main ( String [ ] args ) { int num = 100 , divisor = 7 ; Console . WriteLine ( getRemainder ( num , divisor ) ) ; } }


"Program to find remainder without using modulo or % operator | C # program to find remainder without using modulo operator ; This function returns remainder of num / divisor without using % ( modulo ) operator ; Driver program to test above functions"
Solution in C#:

using System ; class GFG { static int getRemainder ( int num , int divisor ) { return ( num - divisor * ( num / divisor ) ) ; } public static void Main ( ) { Console . Write ( getRemainder ( 100 , 7 ) ) ; } }


"Program to find simple interest | A Simple C # program to compute simple interest for given principal amount , time and rate of interest . ; Driver Code ; We can change values here for different inputs ; Calculate simple interest"
Solution in C#:

using System ; class GFG { public static void Main ( ) { float P = 1 , R = 1 , T = 1 ; float SI = ( P * T * R ) / 100 ; Console . Write ( " Simple ▁ interest ▁ = ▁ " + SI ) ; } }


"Program to find simple moving average | C # program to calculate Simple Moving Average ; queue used to store list so that we get the average ; constructor to initialize period ; function to add new data in the list and update the sum so that we get the new mean ; Updating size so that length of data set should be equal to period as a normal mean has ; function to calculate mean ; Driver code"
Solution in C#:

using System ; using System . Collections . Generic ; public class SimpleMovingAverage { private Queue < Double > Dataset = new Queue < Double > ( ) ; private int period ; private double sum ; public SimpleMovingAverage ( int period ) { this . period = period ; } public void addData ( double num ) { sum += num ; Dataset . Enqueue ( num ) ; if ( Dataset . Count > period ) { sum -= Dataset . Dequeue ( ) ; } } public double getMean ( ) { return sum / period ; } public static void Main ( String [ ] args ) { double [ ] input_data = { 1 , 3 , 5 , 6 , 8 , 12 , 18 , 21 , 22 , 25 } ; int per = 3 ; SimpleMovingAverage obj = new SimpleMovingAverage ( per ) ; foreach ( double x in input_data ) { obj . addData ( x ) ; Console . WriteLine ( " New ▁ number ▁ added ▁ is ▁ " + x + " , ▁ SMA ▁ = ▁ " + obj . getMean ( ) ) ; } } }


"Program to find slant height of cone and pyramid | C # program for the above approach ; Function to calculate slant height of a cone ; Store the slant height of cone ; Print the result ; Function to find the slant height of a pyramid ; Store the slant height of pyramid ; Print the result ; Driver Code ; Dimensions of Cone ; Function Call for slant height of Cone ; Dimensions of Pyramid ; Function to calculate slant height of a pyramid"
Solution in C#:

using System ; public class GFG { static void coneSlantHeight ( double cone_h , double cone_r ) { double slant_height_cone = Math . Sqrt ( Math . Pow ( cone_h , 2 ) + Math . Pow ( cone_r , 2 ) ) ; Console . WriteLine ( " Slant ▁ height ▁ of ▁ cone ▁ is : ▁ " + slant_height_cone ) ; } static void pyramidSlantHeight ( double pyramid_h , double pyramid_s ) { double slant_height_pyramid = Math . Sqrt ( Math . Pow ( pyramid_s / 2 , 2 ) + Math . Pow ( pyramid_h , 2 ) ) ; Console . WriteLine ( " Slant ▁ height ▁ of ▁ pyramid ▁ is : ▁ " + slant_height_pyramid ) ; } public static void Main ( string [ ] args ) { double H1 = 4.5 , R = 6 ; coneSlantHeight ( H1 , R ) ; double H2 = 4 , S = 4.8 ; pyramidSlantHeight ( H2 , S ) ; } }


"Program to find slope of a line | C # program for slope of line ; function to find the slope of a straight line ; driver code to check the above function"
Solution in C#:

using System ; class GFG { static float slope ( float x1 , float y1 , float x2 , float y2 ) { if ( x1 == x2 ) return 1000000000 ; return ( y2 - y1 ) / ( x2 - x1 ) ; } public static void Main ( string [ ] args ) { float x1 = 4 , y1 = 2 ; float x2 = 2 , y2 = 5 ; Console . Write ( " Slope ▁ is : ▁ " + slope ( x1 , y1 , x2 , y2 ) ) ; } }


"Program to find sum of 1 + x / 2 ! + x ^ 2 / 3 ! + ... + x ^ n / ( n + 1 ) ! | C # Program to compute sum of 1 + x / 2 ! + x ^ 2 / 3 ! + ... + x ^ n / ( n + 1 ) ! ; Method to find factorial of a number ; Method to compute the sum ; Iterate the loop till n and compute the formula ; Driver Code ; Get x and n ; Find and print the sum"
Solution in C#:

using System ; class SumOfSeries { static int fact ( int n ) { if ( n == 1 ) return 1 ; return n * fact ( n - 1 ) ; } static double sum ( int x , int n ) { double total = 1.0 ; for ( int i = 1 ; i <= n ; i ++ ) { total = total + ( Math . Pow ( x , i ) / fact ( i + 1 ) ) ; } return total ; } public static void Main ( ) { int x = 5 , n = 4 ; Console . WriteLine ( " Sum ▁ is : ▁ " + sum ( x , n ) ) ; } }


"Program to find sum of 1 + x / 2 ! + x ^ 2 / 3 ! + ... + x ^ n / ( n + 1 ) ! | C # implementation of the approach ; Function to compute the series sum ; To store the value of S [ i - 1 ] ; Iterate over n to store sum in total ; Update previous with S [ i ] ; Driver code ; Get x and n ; Find and print the sum"
Solution in C#:

using System ; class GFG { public double sum ( int x , int n ) { double total = 1.0 ; double previous = 1.0 ; for ( int i = 1 ; i <= n ; i ++ ) { previous = ( ( previous * x ) / ( i + 1 ) ) ; total = total + previous ; } return total ; } } class geek { public static void Main ( ) { GFG g = new GFG ( ) ; int x = 5 , n = 4 ; Console . WriteLine ( " Sum ▁ is : ▁ " + g . sum ( x , n ) ) ; } }


"Program to find sum of first n natural numbers | C # program to find sum of first n natural numbers . ; Returns sum of first n natural numbers ; Driver code"
Solution in C#:

using System ; class GFG { static int findSum ( int n ) { int sum = 0 ; for ( int x = 1 ; x <= n ; x ++ ) sum = sum + x ; return sum ; } public static void Main ( ) { int n = 5 ; Console . Write ( findSum ( n ) ) ; } }


"Program to find sum of first n natural numbers | Efficient C # program to find sum of first n natural numbers . ; Returns sum of first n natural numbers ; Driver code"
Solution in C#:

using System ; class GFG { static int findSum ( int n ) { return n * ( n + 1 ) / 2 ; } public static void Main ( ) { int n = 5 ; Console . Write ( findSum ( n ) ) ; } }


"Program to find sum of first n natural numbers | Efficient C # program to find the sum of first n natural numbers that avoid overflow if result is going to be within limits . ; Returns sum of first n natural numbers ; If n is odd , ( n + 1 ) must be even ; Driver code"
Solution in C#:

using System ; class GFG { static int findSum ( int n ) { if ( n % 2 == 0 ) return ( n / 2 ) * ( n + 1 ) ; else return ( ( n + 1 ) / 2 ) * n ; } public static void Main ( ) { int n = 5 ; Console . Write ( findSum ( n ) ) ; } }


"Program to find sum of harmonic series | C # Program to find sum of harmonic series ; Function to return sum of harmonic series ; Driven Program"
Solution in C#:

using System ; class GFG { static float sum ( int n ) { double i , s = 0.0 ; for ( i = 1 ; i <= n ; i ++ ) s = s + 1 / i ; return ( float ) s ; } public static void Main ( ) { int n = 5 ; Console . WriteLine ( " Sum ▁ is ▁ " + sum ( n ) ) ; } }


"Program to find sum of harmonic series | C # program to find sum of harmonic series using recursion ; Base condition ; Driven Code"
Solution in C#:

using System ; class GFG { static float sum ( float n ) { if ( n < 2 ) return 1 ; else return 1 / n + ( sum ( n - 1 ) ) ; } public static void Main ( ) { Console . WriteLine ( sum ( 8 ) ) ; Console . WriteLine ( sum ( 10 ) ) ; } }


"Program to find sum of series 1 * 2 * 3 + 2 * 3 * 4 + 3 * 4 * 5 + . . . + n * ( n + 1 ) * ( n + 2 ) | C # Program to find the sum of series 1 * 2 * 3 + 2 * 3 * 4 + . . . + n * ( n + 1 ) * ( n + 1 ) ; Function to calculate sum of series . ; Driver Code"
Solution in C#:

using System ; public class GfG { static int sumOfSeries ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum = sum + i * ( i + 1 ) * ( i + 2 ) ; return sum ; } public static void Main ( ) { int n = 10 ; Console . WriteLine ( sumOfSeries ( n ) ) ; } }


"Program to find sum of series 1 + 1 / 2 + 1 / 3 + 1 / 4 + . . + 1 / n | C # Program to find sum of series ; Function to return sum of 1 / 1 + 1 / 2 + 1 / 3 + . . + 1 / n ; Driven Program"
Solution in C#:


"Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n | C # Program to find sum of series 1 + 2 + 2 + 3 + . . . + n ; Function that find sum of series . ; Driver Code ; Function call"
Solution in C#:

using System ; class GfG { static int sumOfSeries ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum = sum + i * i ; return sum ; } public static void Main ( ) { int n = 10 ; Console . WriteLine ( sumOfSeries ( n ) ) ; } }


using System ; public class GfG { static int sumOfSeries ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= i ; j ++ ) sum = sum + i ; return sum ; } public static void Main ( ) { int n = 10 ; Console . Write ( sumOfSeries ( n ) ) ; } }


"Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n | C # Program to find sum of series 1 + 2 + 2 + 3 + . . . + n ; Function that find sum of series . ; Driver Code"
Solution in C#:

using System ; public class GfG { static int sumOfSeries ( int n ) { return ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; } public static void Main ( ) { int n = 10 ; Console . WriteLine ( sumOfSeries ( n ) ) ; } }


"Program to find sum of the given sequence | C # program to find the sum of the given sequence ; function to find moudulo inverse under 10 ^ 9 + 7 ; Function to find the sum of the given sequence ; Driver code"
Solution in C#:

using System ; class gfg { public long MOD = 1000000007 ; public long modInv ( long x ) { long n = MOD - 2 ; long result = 1 ; while ( n > 0 ) { if ( ( n & 1 ) > 0 ) result = result * x % MOD ; x = x * x % MOD ; n = n / 2 ; } return result ; } public long getSum ( long n , long k ) { long ans = 1 ; for ( long i = n + 1 ; i > n - k ; i -- ) ans = ans * i % MOD ; ans = ans * modInv ( k + 1 ) % MOD ; return ans ; } } class geek { public static int Main ( ) { gfg g = new gfg ( ) ; long n = 3 , k = 2 ; Console . WriteLine ( g . getSum ( n , k ) ) ; return 0 ; } }


"Program to find the Area and Perimeter of a Semicircle | C # program to find the Area and Perimeter of a Semicircle ; Function for calculating the area ; Formula for finding the area ; Function for calculating the perimeter ; Formula for finding the perimeter ; Driver Code ; Get the radius ; Find the area ; Find the perimeter"
Solution in C#:

using System ; class GFG { static float area ( float r ) { return ( float ) ( ( 0.5 ) * ( 3.14 ) * ( r * r ) ) ; } static float perimeter ( float r ) { return ( float ) ( ( 3.14 ) * ( r ) ) ; } public static void Main ( ) { float r = 10 ; Console . WriteLine ( " The ▁ Area ▁ of ▁ Semicircle : ▁ " + area ( r ) ) ; Console . WriteLine ( " The ▁ Perimeter ▁ of ▁ Semicircle : " + perimeter ( r ) ) ; } }


"Program to find the Area and Volume of Icosahedron | C # program to find the Area and volume of Icosahedron ; Function to find area of Icosahedron ; Formula to calculating area ; Function to find volume of Icosahedron ; Formula to calculating volume ; Driver code ; Function call to find area of Icosahedron . ; Function call to find volume of Icosahedron ."
Solution in C#:

using System ; public class GFG { static float findArea ( float a ) { float area ; area = ( float ) ( 5 * Math . Sqrt ( 3 ) * a * a ) ; return area ; } static float findVolume ( float a ) { float volume ; volume = ( float ) ( ( ( float ) 5 / 12 ) * ( 3 + Math . Sqrt ( 5 ) ) * a * a * a ) ; return volume ; } static public void Main ( ) { float a = 5 ; Console . WriteLine ( " Area : ▁ " + findArea ( a ) ) ; Console . WriteLine ( " Volume : ▁ " + findVolume ( a ) ) ; } }


"Program to find the Area of an Ellipse | C # program to find area of an Ellipse . ; Function to find area of an ellipse . ; formula to find the area of an Ellipse . ; Display the result ; Driver code"
Solution in C#:

using System ; class GFG { static void findArea ( float a , float b ) { float Area ; Area = ( float ) 3.142 * a * b ; Console . WriteLine ( " Area : ▁ " + Area ) ; } public static void Main ( ) { float a = 5 , b = 4 ; findArea ( a , b ) ; } }


"Program to find the Break Even Point | C # program to find Break Even Point ; Function to calculate Break Even Point ; Calculating number of articles to be sold ; Driver Code"
Solution in C#:

using System ; class GFG { public static int breakEvenPoint ( int exp1 , int S , int M ) { double earn = S - M ; double exp = exp1 ; double res = Math . Ceiling ( exp / earn ) ; int res1 = ( int ) res ; return res1 ; } public static void Main ( ) { int exp = 3550 , S = 90 , M = 65 ; Console . WriteLine ( breakEvenPoint ( exp , S , M ) ) ; } }


"Program to find the Circumcircle of any regular polygon | C # Program to find the radius of the circumcircle of the given polygon ; Function to find the radius of the circumcircle ; these cannot be negative ; Radius of the circumcircle ; Return the radius ; Driver code ; Find the radius of the circumcircle"
Solution in C#:

using System ; class GFG { static float findRadiusOfcircumcircle ( float n , float a ) { if ( n < 0 a < 0 ) return - 1 ; float radius = ( float ) ( a / Math . Sqrt ( 2 - ( 2 * Math . Cos ( 360 / n ) ) ) ) ; return radius ; } public static void Main ( ) { float n = 5 , a = 6 ; Console . WriteLine ( findRadiusOfcircumcircle ( n , a ) ) ; } }


"Program to find the Depreciation of Value | C # program to find depreciation of the value initial value , rate and time are given ; Function to return the depreciation of value ; Driver code"
Solution in C#:

using System ; class GFG { static float Depreciation ( float v , float r , float t ) { float D = ( float ) ( v * Math . Pow ( ( 1 - r / 100 ) , t ) ) ; return D ; } public static void Main ( ) { float V1 = 200 , R = 10 , T = 2 ; Console . WriteLine ( Depreciation ( V1 , R , T ) ) ; } }


"Program to find the Hidden Number | C # Program to find the hidden number ; Driver Code ; Getting the size of array ; Getting the array of size n ; Solution ; Finding sum of the array elements ; Dividing sum by size n ; Print x , if found"
Solution in C#:

using System ; class GFG { public static void Main ( ) { int n = 3 ; int [ ] a = { 1 , 2 , 3 } ; int i = 0 ; long sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } long x = sum / n ; if ( x * n == sum ) Console . WriteLine ( x ) ; else Console . WriteLine ( " - 1" ) ; } }


"Program to find the Interior and Exterior Angle of a Regular Polygon | C # program to find the interior and exterior angle of a given polygon ; function to find the interior and exterior angle ; formula to find the interior angle ; formula to find the exterior angle ; Displaying the output ; Driver code ; Function calling"
Solution in C#:

 using System ; class GFG { static void findAngle ( int n ) { int interiorAngle , exteriorAngle ; interiorAngle = ( n - 2 ) * 180 / n ; exteriorAngle = 360 / n ; Console . Write ( " Interior ▁ angle : ▁ " + interiorAngle + "
 " ) ; Console . Write ( " Exterior ▁ angle : ▁ " + exteriorAngle ) ; } public static void Main ( ) { int n = 10 ; findAngle ( n ) ; } }


"Program to find the LCM of two prime numbers | C # program to find LCM of two prime numbers ; Function to return the LCM of two prime numbers ; If the two numbers are equal then return any one of a and b ; Else return product of numbers ; Driver code ; Given two numbers ; Function Call"
Solution in C#:

using System ; class GFG { static int findLCMPrime ( int a , int b ) { if ( a == b ) { return a ; } return a * b ; } public static void Main ( string [ ] args ) { int a = 3 , b = 5 ; Console . WriteLine ( findLCMPrime ( a , b ) ) ; } }


"Program to find the Nth Composite Number | C # program for the above approach ; Function to find the Nth Composite Numbers using Sieve of Eratosthenes ; Sieve of prime numbers ; Initialize the array to true ; Iterate over the range [ 2 , MAX_SIZE ] ; If IsPrime [ p ] is true ; Iterate over the range [ p * p , MAX_SIZE ] ; Stores the list of composite numbers ; Iterate over the range [ 4 , MAX_SIZE ] ; If i is not prime ; Return Nth Composite Number ; Driver Code"
Solution in C#:

using System ; using System . Collections . Generic ; public class GFG { public static int NthComposite ( int N ) { int MAX_SIZE = 1000005 ; bool [ ] IsPrime = new bool [ MAX_SIZE ] ; Array . Fill ( IsPrime , true ) ; for ( int p = 2 ; p * p < MAX_SIZE ; p ++ ) { if ( IsPrime [ p ] == true ) { for ( int i = p * p ; i < MAX_SIZE ; i += p ) IsPrime [ i ] = false ; } } List < int > Composites = new List < int > ( ) ; for ( int p = 4 ; p < MAX_SIZE ; p ++ ) if ( ! IsPrime [ p ] ) Composites . Add ( p ) ; return Composites [ N - 1 ] ; } static public void Main ( ) { int N = 4 ; Console . WriteLine ( NthComposite ( N ) ) ; } }


"Program to find the Nth Harmonic Number | C # program to find N - th Harmonic Number ; Function to find N - th Harmonic Number ; H1 = 1 ; loop to apply the forumula Hn = H1 + H2 + H3 ... + Hn - 1 + Hn - 1 + 1 / n ; Driver Code"
Solution in C#:

using System ; class GFG { static double nthHarmonic ( int N ) { float harmonic = 1 ; for ( int i = 2 ; i <= N ; i ++ ) { harmonic += ( float ) 1 / i ; } return harmonic ; } static public void Main ( ) { int N = 8 ; Console . Write ( nthHarmonic ( N ) ) ; } }


"Program to find the Nth natural number with exactly two bits set | C # Code to find the Nth number with exactly two bits set ; Function to find the Nth number with exactly two bits set ; Keep incrementing until we reach the partition of ' N ' stored in bit_L ; set the rightmost bit based on bit_R ; Driver code"
Solution in C#:

 using System ; class GFG { static void findNthNum ( int N ) { int bit_L = 1 , last_num = 0 ; while ( bit_L * ( bit_L + 1 ) / 2 < N ) { last_num = last_num + bit_L ; bit_L ++ ; } int bit_R = N - last_num - 1 ; Console . Write ( ( 1 << bit_L ) + ( 1 << bit_R ) + "
 " ) ; } public static void Main ( String [ ] args ) { int N = 13 ; findNthNum ( N ) ; } }


"Program to find the Nth natural number with exactly two bits set | Set 2 | C # program for the above approach ; Function to find the Nth number with exactly two bits set ; Initialize the range in which the value of ' a ' is present ; Perform Binary Search ; Find the mid value ; Update the range using the mid value t ; Find b value using a and N ; Print the value 2 ^ a + 2 ^ b ; Driver Code ; Function Call"
Solution in C#:

using System ; class GFG { static void findNthNum ( int N ) { left = 1 ; right = N ; while ( left <= right ) { mid = left + ( right - left ) / 2 ; t = ( mid * ( mid + 1 ) ) / 2 ; if ( t < N ) { left = mid + 1 ; } else if ( t == N ) { a = mid ; break ; } else { a = mid ; right = mid - 1 ; } } t = a - 1 ; b = N - ( t * ( t + 1 ) ) / 2 - 1 ; Console . Write ( ( 1 << a ) + ( 1 << b ) ) ; } public static void Main ( ) { int N = 15 ; findNthNum ( N ) ; } }


"Program to find the Nth natural number with exactly two bits set | Set 2 | C # program for the above approach ; Function to find the Nth number with exactly two bits set ; Initialize variables ; Initialize the range in which the value of ' a ' is present ; Perform Binary Search ; Find the mid value ; Update the range using the mid value t ; Find b value using a and N ; Print the value 2 ^ a + 2 ^ b ; Driver Code ; Function Call"
Solution in C#:

using System ; class GFG { static void findNthNum ( int N ) { int a = 0 , b , left ; int right , mid ; int t ; left = 1 ; right = N ; while ( left <= right ) { mid = left + ( right - left ) / 2 ; t = ( mid * ( mid + 1 ) ) / 2 ; if ( t < N ) { left = mid + 1 ; } else if ( t == N ) { a = mid ; break ; } else { a = mid ; right = mid - 1 ; } } t = a - 1 ; b = N - ( t * ( t + 1 ) ) / 2 - 1 ; Console . Write ( ( 1 << a ) + ( 1 << b ) ) ; } public static void Main ( ) { int N = 15 ; findNthNum ( N ) ; } }


"Program to find the Nth number of the series 2 , 10 , 24 , 44 , 70. ... . | C # program to find N - th term of the series : ; function to return nth term of the series ; Driver Code ; Taking n as 4 ; Printing the nth term"
Solution in C#:

using System ; class GFG { static long NthTerm ( long n ) { long x = ( 3 * n * n ) % 1000000009 ; return ( x - n + 1000000009 ) % 1000000009 ; } public static void Main ( ) { long N = 4 ; Console . Write ( NthTerm ( N ) ) ; } }


"Program to find the Nth term of series 5 , 10 , 17 , 26 , 37 , 50 , 65 , 82 , ... | C # program to find the N - th term of the series : 5 , 10 , 17 , 26 , 37 , 50 , 65 , 82 , ... ; calculate Nth term of series ; return the final sum ; Driver Code"
Solution in C#:

using System ; class GFG { static int nthTerm ( int n ) { return ( int ) Math . Pow ( n , 2 ) + 2 * n + 2 ; } public static void Main ( ) { int N = 4 ; Console . Write ( nthTerm ( N ) ) ; } }


"Program to find the Nth term of series 5 , 12 , 21 , 32 , 45. ... . . | C # program to find the N - th term of the series : 5 , 12 , 21 , 32 , 45. . ... . ; calculate Nth term of series ; Driver code"
Solution in C#:

using System ; class GFG { static int nthTerm ( int n ) { return ( int ) Math . Pow ( n , 2 ) + 4 * n ; } public static void Main ( ) { int N = 4 ; Console . WriteLine ( nthTerm ( N ) ) ; } }


"Program to find the Nth term of series | C # program to find N - th term of the series : 9 , 23 , 45 , 75 , 113 , 159. . ... . ; calculate Nth term of series ; Driver code ; Get the value of N ; Find the Nth term and print it"
Solution in C#:

using System ; class GFG { static int nthTerm ( int N ) { return ( ( 3 * N * N ) - ( 6 * N ) + 2 ) ; } public static void Main ( ) { int N = 3 ; Console . WriteLine ( nthTerm ( N ) ) ; } }


"Program to find the Nth term of the series 0 , 14 , 40 , 78 , 124 , ... | C # program to find the N - th term of the series 0 , 14 , 40 , 78 , 124 . . . ; calculate sum up to Nth term of series ; return the final sum ; Driver code"
Solution in C#:

using System ; class GFG { static int nthTerm ( int n ) { return 6 * ( int ) Math . Pow ( n , 2 ) - 4 * n - 2 ; } public static void Main ( ) { int N = 4 ; Console . WriteLine ( nthTerm ( N ) ) ; } }


"Program to find the Nth term of the series 0 , 3 / 1 , 8 / 3 , 15 / 5. . ... ... | C # implementation of the approach ; Function to return the nth term of the given series ; nth term ; Driver code"
Solution in C#:

using System ; public class GFG { static void NthTerm ( int n ) { int numerator = ( ( int ) Math . Pow ( n , 2 ) ) - 1 ; int denomeanator = 2 * n - 3 ; Console . WriteLine ( numerator + " / " + denomeanator ) ; } public static void Main ( ) { int n = 3 ; NthTerm ( n ) ; } }


"Program to find the Nth term of the series 0 , 5 , 14 , 27 , 44 , ... ... . . | C # program to find N - th term of the series : 0 , 5 , 14 , 27 , 44 . . . ; Calculate Nth term of series ; Driver code"
Solution in C#:

using System ; class GFG { static int nthTerm ( int n ) { return 2 * ( int ) Math . Pow ( n , 2 ) - n - 1 ; } static public void Main ( ) { int N = 4 ; Console . Write ( nthTerm ( N ) ) ; } }


"Program to find the Nth term of the series 0 , 5 , 18 , 39 , 67 , 105 , 150 , 203 , ... | C # program to find the N - th term of the series : 0 , 5 , 18 , 39 , 67 , 105 , 150 , 203 , ; calculate Nth term of series ; Driver code"
Solution in C#:

using System ; class GFG { static int nthTerm ( int n ) { return 4 * ( int ) Math . Pow ( n , 2 ) - 7 * n + 3 ; } static public void Main ( ) { int N = 4 ; Console . Write ( nthTerm ( N ) ) ; } }


"Program to find the Nth term of the series 3 , 20 , 63 , 144 , 230 , â €¦ â €¦ | C # program to find N - th term of the series : 3 , 20 , 63 , 144 , 230 . ... . ; calculate Nth term of series ; return final sum ; Driver code"
Solution in C#:

using System ; class solution { static int nthTerm ( int n ) { return 2 * ( int ) Math . Pow ( n , 3 ) + ( int ) Math . Pow ( n , 2 ) ; } public static void Main ( ) { int N = 3 ; Console . WriteLine ( nthTerm ( N ) ) ; } }


"Program to find the Nth term of the series 3 , 7 , 13 , 21 , 31. ... . | C # code to find the Nth term of given series . ; Function to calculate sum ; Return Nth term ; Driver Code ; declaration of number of terms ; Get the Nth term"
Solution in C#:

using System ; class GFG { static long getNthTerm ( long N ) { return ( ( int ) Math . Pow ( N , 2 ) + N + 1 ) ; } static public void Main ( ) { long N = 11 ; Console . Write ( getNthTerm ( N ) ) ; } }


"Program to find the Radius of the incircle of the triangle | C # Program to find the radius of the incircle of the given triangle ; Function to find the radius of the incircle ; the sides cannot be negative ; semi - perimeter of the circle ; area of the triangle ; Radius of the incircle ; Return the radius ; Driver code ; Get the sides of the triangle ; Find the radius of the incircle"
Solution in C#:

using System ; class GFG { public static float findRadiusOfIncircle ( float a , float b , float c ) { if ( a < 0 b < 0 c < 0 ) return - 1 ; float p = ( a + b + c ) / 2 ; float area = ( float ) Math . Sqrt ( p * ( p - a ) * ( p - b ) * ( p - c ) ) ; float radius = area / p ; return ( float ) ( radius ) ; } public static void Main ( ) { float a = 2 , b = 2 , c = 3 ; Console . WriteLine ( findRadiusOfIncircle ( a , b , c ) ) ; } }


"Program to find the Roots of Quadratic equation | C # program to find roots of a quadratic equation ; Prints roots of quadratic equation ax * 2 + bx + x ; If a is 0 , then equation is not quadratic , but linear ; d < 0 ; Driver code ; Function call"
Solution in C#:

 using System ; class Quadratic { void findRoots ( int a , int b , int c ) { if ( a == 0 ) { Console . Write ( " Invalid " ) ; return ; } int d = b * b - 4 * a * c ; double sqrt_val = Math . Abs ( d ) ; if ( d > 0 ) { Console . Write ( " Roots ▁ are ▁ real ▁ and ▁ different ▁
 " ) ; Console . Write ( ( double ) ( - b + sqrt_val ) / ( 2 * a ) + "
 " + ( double ) ( - b - sqrt_val ) / ( 2 * a ) ) ; } else { Console . Write ( " Roots ▁ are ▁ complex ▁
 " ) ; Console . Write ( - ( double ) b / ( 2 * a ) + " ▁ + ▁ i " + sqrt_val + "
 " + - ( double ) b / ( 2 * a ) + " ▁ - ▁ i " + sqrt_val ) ; } } public static void Main ( ) { Quadratic obj = new Quadratic ( ) ; int a = 1 , b = - 7 , c = 12 ; obj . findRoots ( a , b , c ) ; } }


"Program to find the Speed of train as per speed of sound | C # implementation of the approach ; Function to find the Speed of train ; Driver code ; calling Function"
Solution in C#:

using System ; class GFG { static int speedOfTrain ( float X , float Y ) { float Speed ; Speed = 1188 * ( ( X - Y ) / Y ) ; return ( int ) Speed ; } public static void Main ( ) { float X = 8f , Y = 7.2f ; int result = ( speedOfTrain ( X , Y ) ) ; Console . Write ( result + " ▁ km / hr " ) ; } }


"Program to find the Type of Triangle from the given Coordinates | C # program to classify a given triangle ; Utility method to return square of x ; Utility method to sort a , b , c ; after this method a <= b <= c ; Utility method to return Square of distance between two points ; Method to classify side ; if all sides are equal ; if any two sides are equal ; Method to classify angle ; If addition of sum of square of two side is less , then acute ; by pythagoras theorem ; Method to classify the triangle by sides and angles ; Find squares of distances between points ; Sort all squares of distances in increasing order ; Driver code"
Solution in C#:

using System ; class GFG { public class point { public int x , y ; public point ( ) { } public point ( int x , int y ) { this . x = x ; this . y = y ; } } ; static int square ( int x ) { return x * x ; } static int a , b , c ; static void order ( ) { int [ ] copy = new int [ 3 ] ; copy [ 0 ] = a ; copy [ 1 ] = b ; copy [ 2 ] = c ; Array . Sort ( copy ) ; a = copy [ 0 ] ; b = copy [ 1 ] ; c = copy [ 2 ] ; } static int euclidDistSquare ( point p1 , point p2 ) { return square ( p1 . x - p2 . x ) + square ( p1 . y - p2 . y ) ; } static String getSideClassification ( int a , int b , int c ) { if ( a == b && b == c ) return " Equilateral " ; else if ( a == b b == c ) return " Isosceles " ; else return " Scalene " ; } static String getAngleClassification ( int a , int b , int c ) { if ( a + b > c ) return " acute " ; else if ( a + b == c ) return " right " ; else return " obtuse " ; } static void classifyTriangle ( point p1 , point p2 , point p3 ) { a = euclidDistSquare ( p1 , p2 ) ; b = euclidDistSquare ( p1 , p3 ) ; c = euclidDistSquare ( p2 , p3 ) ; order ( ) ; Console . WriteLine ( " Triangle ▁ is ▁ " + getAngleClassification ( a , b , c ) + " ▁ and ▁ " + getSideClassification ( a , b , c ) ) ; } public static void Main ( String [ ] args ) { point p1 , p2 , p3 ; p1 = new point ( 3 , 0 ) ; p2 = new point ( 0 , 4 ) ; p3 = new point ( 4 , 7 ) ; classifyTriangle ( p1 , p2 , p3 ) ; p1 = new point ( 0 , 0 ) ; p2 = new point ( 1 , 1 ) ; p3 = new point ( 1 , 2 ) ; classifyTriangle ( p1 , p2 , p3 ) ; } }


"Program to find the Volume of an irregular tetrahedron | C # implementation of above approach ; Function to find the volume ; Steps to calculate volume of a Tetrahedron using formula ; Driver code ; edge lengths"
Solution in C#:

using System ; class GFG { static void findVolume ( double u , double v , double w , double U , double V , double W , double b ) { double uPow = Math . Pow ( u , 2 ) ; double vPow = Math . Pow ( v , 2 ) ; double wPow = Math . Pow ( w , 2 ) ; double UPow = Math . Pow ( U , 2 ) ; double VPow = Math . Pow ( V , 2 ) ; double WPow = Math . Pow ( W , 2 ) ; double a = 4 * ( uPow * vPow * wPow ) - uPow * Math . Pow ( ( vPow + wPow - UPow ) , 2 ) - vPow * Math . Pow ( ( wPow + uPow - VPow ) , 2 ) - wPow * Math . Pow ( ( uPow + vPow - WPow ) , 2 ) + ( vPow + wPow - UPow ) * ( wPow + uPow - VPow ) * ( uPow + vPow - WPow ) ; double vol = Math . Sqrt ( a ) ; vol /= b ; Console . Write ( System . Math . Round ( vol , 4 ) ) ; } public static void Main ( ) { double u = 1000 , v = 1000 , w = 1000 ; double U = 3 , V = 4 , W = 5 ; double b = 12 ; findVolume ( u , v , w , U , V , W , b ) ; } }


"Program to find the XOR of ASCII values of characters in a string | C # program to find XOR of ASCII value of characters in String ; Function to find the XOR of ASCII value of characters in String ; store value of first character ; Traverse String to find the XOR ; Return the XOR ; Driver code"
Solution in C#:

 using System ; class GFG { static int XorAscii ( String str , int len ) { int ans = ( str [ 0 ] ) ; for ( int i = 1 ; i < len ; i ++ ) { ans = ( ans ^ ( ( str [ i ] ) ) ) ; } return ans ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; int len = str . Length ; Console . Write ( XorAscii ( str , len ) + "
 " ) ; str = " GfG " ; len = str . Length ; Console . Write ( XorAscii ( str , len ) ) ; } }


"Program to find the common ratio of three numbers | C # implementation of above approach ; Utility function ; Function to print a : b : c ; To print the given proportion in simplest form . ; Driver code ; Get the ratios ; Get ratio a : b1 ; Get ratio b2 : c ; Find the ratio a : b : c"
Solution in C#:

using System ; class GFG { static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static void solveProportion ( int a , int b1 , int b2 , int c ) { int A = a * b2 ; int B = b1 * b2 ; int C = b1 * c ; int gcd = __gcd ( __gcd ( A , B ) , C ) ; Console . Write ( A / gcd + " : " + B / gcd + " : " + C / gcd ) ; } public static void Main ( ) { int a , b1 , b2 , c ; a = 3 ; b1 = 4 ; b2 = 8 ; c = 9 ; solveProportion ( a , b1 , b2 , c ) ; } }


"Program to find the count of coins of each type from the given ratio | C # implementation of above approach ; function to calculate coin . ; Converting each of them in rupees . As we are given totalRupees = 1800 ; Driver code"
Solution in C#:

using System ; class GFG { static int coin ( int totalRupees , int X , int Y , int Z ) { float one = 0 , fifty = 0 , twentyfive = 0 , result = 0 , total = 0 ; one = X * 1 ; fifty = ( ( Y * 1 ) / 2 ) ; twentyfive = ( ( Z * 1 ) / 4 ) ; total = one + fifty + twentyfive ; result = ( ( totalRupees ) / total ) ; return ( int ) result ; } public static void Main ( ) { int totalRupees = 1800 ; int X = 1 , Y = 2 , Z = 4 ; int Rupees = coin ( totalRupees , X , Y , Z ) ; Console . WriteLine ( "1 ▁ rupess ▁ coins ▁ = ▁ " + Rupees * 1 ) ; Console . WriteLine ( "50 ▁ paisa ▁ coins ▁ = ▁ " + Rupees * 2 ) ; Console . WriteLine ( "25 ▁ paisa ▁ coins ▁ = ▁ " + Rupees * 4 ) ; } }


"Program to find the kth character after decrypting a string | C # implementation of the approach ; Function to print kth character of String s after decrypting it ; Get the length of string ; Initialise pointer to character of input string to zero ; Total length of resultant string ; Traverse the string from starting and check if each character is alphabet then increment total_len ; If total_leg equal to k then return string else increment i ; Parse the number ; Update next_total_len ; Get the position of kth character ; Position not found then update position with total_len ; Recursively find the kth position ; Else update total_len by next_total_len ; Return - 1 if character not found ; Driver code"
Solution in C#:

using System ; class GFG { static char findKthChar ( String s , int k ) { int len = s . Length ; int i = 0 ; int total_len = 0 ; while ( i < len ) { if ( char . IsLetter ( s [ i ] ) ) { total_len ++ ; if ( total_len == k ) return s [ i ] ; i ++ ; } else { int n = 0 ; while ( i < len && ! char . IsLetter ( s [ i ] ) ) { n = n * 10 + ( s [ i ] - '0' ) ; i ++ ; } int next_total_len = total_len * n ; if ( k <= next_total_len ) { int pos = k % total_len ; if ( pos == 0 ) { pos = total_len ; } return findKthChar ( s , pos ) ; } else { total_len = next_total_len ; } } } return ' ▁ ' ; } public static void Main ( String [ ] args ) { String s = " ab2c3" ; int k = 5 ; Console . WriteLine ( findKthChar ( s , k ) ) ; } }


"Program to find the last digit of X in base Y | C # Program to find the last digit of X in base Y ; Function to find the last digit of X in base Y ; Driver code"
Solution in C#:

using System ; class GFG { static void last_digit ( int X , int Y ) { Console . Write ( X % Y ) ; } public static void Main ( String [ ] args ) { int X = 55 , Y = 3 ; last_digit ( X , Y ) ; } }


"Program to find the length of Latus Rectum of a Hyperbola | C # program for the above approach ; Function to calculate the length of the latus rectum of a hyperbola ; Store the length of major axis ; Store the length of minor axis ; Store the length of the latus rectum ; Return the length of the latus rectum ; Driver Code"
Solution in C#:

using System ; class GFG { static double lengthOfLatusRectum ( double A , double B ) { double major = 2.0 * A ; double minor = 2.0 * B ; double latus_rectum = ( minor * minor ) / major ; return latus_rectum ; } public static void Main ( ) { double A = 3.0 , B = 2.0 ; Console . WriteLine ( lengthOfLatusRectum ( A , B ) ) ; } }


"Program to find the length of Latus Rectum of a Parabola | C # program for the above approach ; Function to calculate distance between two points ; Calculating distance ; Function to calculate length of the latus rectum of a parabola ; Stores the co - ordinates of the vertex of the parabola ; Stores the co - ordinates of the focus of parabola ; Print the distance between focus and vertex ; Driver Code ; Given a , b & c ; Function call"
Solution in C#:

using System ; public class GFG { class pair { public float first ; public float second ; public pair ( float first , float second ) { this . first = first ; this . second = second ; } } static float distance ( float x1 , float y1 , float x2 , float y2 ) { return ( float ) Math . Sqrt ( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) ; } static void lengthOfLatusRectum ( float a , float b , float c ) { pair vertex = new pair ( ( - b / ( 2 * a ) ) , ( ( ( 4 * a * c ) - ( b * b ) ) / ( 4 * a ) ) ) ; pair focus = new pair ( ( - b / ( 2 * a ) ) , ( ( ( 4 * a * c ) - ( b * b ) + 1 ) / ( 4 * a ) ) ) ; Console . Write ( 4 * distance ( ( float ) focus . first , ( float ) focus . second , ( float ) vertex . first , ( float ) vertex . second ) ) ; } public static void Main ( String [ ] args ) { float a = 3 , b = 5 , c = 1 ; lengthOfLatusRectum ( a , b , c ) ; } }


"Program to find the maximum difference between the index of any two different numbers | C # implementation of the approach ; Function to return the maximum difference ; Iteratively check from back ; Different numbers ; Iteratively check from the beginning ; Different numbers ; Driver code"
Solution in C#:

using System ; class GFG { static int findMaximumDiff ( int [ ] a , int n ) { int ind1 = 0 ; for ( int i = n - 1 ; i > 0 ; i -- ) { if ( a [ 0 ] != a [ i ] ) { ind1 = i ; break ; } } int ind2 = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ n - 1 ] != a [ i ] ) { ind2 = ( n - 1 - i ) ; break ; } } return Math . Max ( ind1 , ind2 ) ; } static void Main ( ) { int [ ] a = { 1 , 2 , 3 , 2 , 3 } ; int n = a . Length ; Console . WriteLine ( findMaximumDiff ( a , n ) ) ; } }


"Program to find the minimum ( or maximum ) element of an array | C # program to find minimum ( or maximum ) element in an array . ; C # program to find minimum ( or maximum ) element in an array . ; Driver code"
Solution in C#:

using System ; using System . Linq ; class GFG { static int getMin ( int [ ] arr , int n ) { return arr . Min ( ) ; } static int getMax ( int [ ] arr , int n ) { return arr . Max ( ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 1234 , 45 , 67 , 1 } ; int n = arr . Length ; Console . WriteLine ( " Minimum ▁ element ▁ of ▁ array : ▁ " + getMin ( arr , n ) ) ; Console . WriteLine ( " Maximum ▁ element ▁ of ▁ array : ▁ " + getMax ( arr , n ) ) ; } }


"Program to find the minimum ( or maximum ) element of an array | C # program to find minimum ( or maximum ) element in an array . ; If there is single element , return it . Else return minimum of first element and minimum of remaining array . ; If there is single element , return it . Else return maximum of first element and maximum of remaining array . ; Driver code"
Solution in C#:

using System ; class GFG { static int getMin ( int [ ] arr , int i , int n ) { return ( n == 1 ) ? arr [ i ] : Math . Min ( arr [ i ] , getMin ( arr , i + 1 , n - 1 ) ) ; } static int getMax ( int [ ] arr , int i , int n ) { return ( n == 1 ) ? arr [ i ] : Math . Max ( arr [ i ] , getMax ( arr , i + 1 , n - 1 ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 1234 , 45 , 67 , 1 } ; int n = arr . Length ; Console . WriteLine ( " Minimum ▁ element ▁ of ▁ array : ▁ " + getMin ( arr , 0 , n ) ) ; Console . WriteLine ( " Maximum ▁ element ▁ of ▁ array : ▁ " + getMax ( arr , 0 , n ) ) ; } }


"Program to find the next prime number | C # implementation of the approach ; Function that returns true if n is prime else returns false ; Corner cases ; This is checked so that we can skip middle five numbers in below loop ; Function to return the smallest prime number greater than N ; Base case ; Loop continuously until isPrime returns true for a number greater than n ; Driver code"
Solution in C#:

using System ; class GFG { static bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static int nextPrime ( int N ) { if ( N <= 1 ) return 2 ; int prime = N ; bool found = false ; while ( ! found ) { prime ++ ; if ( isPrime ( prime ) ) found = true ; } return prime ; } public static void Main ( String [ ] args ) { int N = 3 ; Console . WriteLine ( nextPrime ( N ) ) ; } }


"Program to find the nth Kynea number | C # code to find nth Kynea number ; Function to calculate nth kynea number ; Calculate nth kynea number ; Driver Program ; print nth kynea number"
Solution in C#:

using System ; class GFG { static long nthKyneaNumber ( int n ) { return ( ( 1 << ( 2 * n ) ) + ( 1 << ( n + 1 ) ) - 1 ) ; } public static void Main ( ) { int n = 2 ; Console . WriteLine ( nthKyneaNumber ( n ) ) ; } }


"Program to find the nth Kynea number | C # code to find nth Kynea number ; Function to calculate nth kynea number ; Firstly calculate 2 ^ n + 1 ; Now calculate ( 2 ^ n + 1 ) ^ 2 ; Now calculate ( ( 2 ^ n + 1 ) ^ 2 ) - 2 ; return nth Kynea number ; Driver Program ; print nth kynea number"
Solution in C#:

using System ; class GFG { static long nthKyneaNumber ( int n ) { n = ( 1 << n ) + 1 ; n = n * n ; n = n - 2 ; return n ; } public static void Main ( ) { int n = 2 ; Console . WriteLine ( nthKyneaNumber ( n ) ) ; } }


"Program to find the number from given holes | C # implementation of the above approach ; Function that will find out the number ; If number of holes equal 0 then return 1 ; If number of holes equal 0 then return 0 ; If number of holes is more than 0 or 1. ; If number of holes is odd ; Driver code ; Calling Function"
Solution in C#:

using System ; class GFG { static void printNumber ( int holes ) { if ( holes == 0 ) Console . Write ( "1" ) ; else if ( holes == 1 ) Console . Write ( "0" ) ; else { int rem = 0 , quo = 0 ; rem = holes % 2 ; quo = holes / 2 ; if ( rem == 1 ) Console . Write ( "4" ) ; for ( int i = 0 ; i < quo ; i ++ ) Console . Write ( "8" ) ; } } static public void Main ( ) { int holes = 3 ; printNumber ( holes ) ; } }


"Program to find the number of region in Planar Graph | C # implementation of the approach ; Function to return the number of regions in a Planar Graph ; Driver code"
Solution in C#:

using System ; class GFG { static int Regions ( int Vertices , int Edges ) { int R = Edges + 2 - Vertices ; return R ; } static public void Main ( ) { int V = 5 , E = 7 ; Console . WriteLine ( Regions ( V , E ) ) ; } }


"Program to find the percentage of difference between two numbers | C # program to calculate the percentage ; Function to calculate the percentage ; Driver Code ; Function calling"
Solution in C#:

class GFG { static int percent ( int a , int b ) { float result = 0 ; result = ( ( b - a ) * 100 ) / a ; return ( int ) result ; } static void Main ( ) { int a = 20 , b = 25 ; System . Console . WriteLine ( percent ( a , b ) + " % " ) ; } }


"Program to find the product of ASCII values of characters in a string | C # program to find product of ASCII value of characters in string ; Function to find product of ASCII value of characters in string ; Traverse string to find the product ; Return the product ; Driver Code"
Solution in C#:

using System ; class GFG { static long productAscii ( String str ) { long prod = 1 ; for ( int i = 0 ; i < str . Length ; i ++ ) { prod *= str [ i ] ; } return prod ; } static public void Main ( ) { String str = " GfG " ; Console . Write ( productAscii ( str ) ) ; } }


"Program to find the profit or loss when CP of N items is equal to SP of M items | C # implementation of above formula ; Function to calculate Profit or loss ; Driver Code"
Solution in C#:

using System ; class GFG { static void profitLoss ( int N , int M ) { if ( N == M ) Console . Write ( " No ▁ Profit ▁ nor ▁ Loss " ) ; else { float result = 0 ; result = ( float ) ( Math . Abs ( N - M ) ) / M ; if ( N - M < 0 ) Console . Write ( " Loss ▁ = ▁ - " + result * 100 + " % " ) ; else Console . Write ( " Profit ▁ = ▁ " + result * 100 + " % " ) ; } } static public void Main ( ) { int N = 8 , M = 9 ; profitLoss ( N , M ) ; } }


"Program to find the quantity after mixture replacement | C # code using above Formula . ; Function to calculate the Remaining amount . ; calculate Right hand Side ( RHS ) . ; calculate Amount left by multiply it with original value . ; Driver Code"
Solution in C#:

using System ; class GFG { static double Mixture ( int X , int Y , int Z ) { double result1 = 0.0 , result = 0.0 ; result1 = ( ( X - Y ) / ( float ) X ) ; result = Math . Pow ( result1 , Z ) ; result = result * X ; return result ; } public static void Main ( ) { int X = 10 , Y = 2 , Z = 2 ; Console . WriteLine ( ( float ) Mixture ( X , Y , Z ) + " ▁ litres " ) ; } }


"Program to find the rate percentage from compound interest of consecutive years | C # implementation of the approach ; Function to return the required rate percentage ; Driver code"
Solution in C#:

using System ; class GFG { static int Rate ( int N1 , int N2 ) { float rate = ( N2 - N1 ) * 100 / N1 ; return ( int ) rate ; } static public void Main ( ) { int N1 = 100 , N2 = 120 ; Console . WriteLine ( Rate ( N1 , N2 ) + " ▁ % " ) ; } }


"Program to find the side of the Octagon inscribed within the square | C # Program to find the side of the octagon which can be inscribed within the square ; Function to find the side of the octagon ; side cannot be negative ; side of the octagon ; Driver code ; Get he square side ; Find the side length of the square"
Solution in C#:

using System ; class GFG { static double octaside ( double a ) { if ( a < 0 ) return - 1 ; double s = a / ( Math . Sqrt ( 2 ) + 1 ) ; return s ; } static public void Main ( ) { double a = 4 ; Console . WriteLine ( octaside ( a ) ) ; } }


"Program to find the smallest element among three elements | C # implementation to find the smallest of three elements"
Solution in C#:

using System ; class GFG { static public void Main ( ) { int a = 5 , b = 7 , c = 10 ; if ( a <= b && a <= c ) Console . WriteLine ( a + " ▁ is ▁ the ▁ smallest " ) ; else if ( b <= a && b <= c ) Console . WriteLine ( b + " ▁ is ▁ the ▁ smallest " ) ; else Console . WriteLine ( c + " ▁ is ▁ the ▁ smallest " ) ; } }


"Program to find the sum of the series 1 + x + x ^ 2 + x ^ 3 + . . + x ^ n | C # implementation to find the sum of series 1 + x ^ 2 + x ^ 3 + ... . + x ^ n ; C # code to print the sum of the given series ; First Term ; Loop to print the N terms of the series and compute their sum ; Driver Code"
Solution in C#:

using System ; class GFG { static double sum ( int x , int n ) { double i , total = 1.0 , multi = x ; Console . Write ( "1 ▁ " ) ; for ( i = 1 ; i < n ; i ++ ) { total = total + multi ; Console . Write ( multi ) ; Console . Write ( " ▁ " ) ; multi = multi * x ; } Console . WriteLine ( ) ; return total ; } public static void Main ( String [ ] args ) { int x = 2 ; int n = 5 ; Console . Write ( " { 0 : F2 } " , sum ( x , n ) ) ; } }


"Program to find the sum of the series 23 + 45 + 75 + ... . . upto N terms | C # program to find sum upto N - th term of the series : 23 , 45 , 75 , 113. . . ; return the final sum ; Driver Code ; Get the value of N ; Get the sum of the series"
Solution in C#:

using System ; class GFG { static int findSum ( int N ) { return ( 2 * N * ( N + 1 ) * ( 4 * N + 17 ) + 54 * N ) / 6 ; } static void Main ( ) { int N = 4 ; Console . Write ( findSum ( N ) ) ; } }


"Program to find the surface area of the square pyramid | C # program to find the surface area Of Square pyramid ; function to find the surface area ; Driver Code ; surface area of the square pyramid"
Solution in C#:

using System ; class GFG { static int surfaceArea ( int b , int s ) { return 2 * b * s + ( int ) Math . Pow ( b , 2 ) ; } public static void Main ( ) { int b = 3 , s = 4 ; Console . WriteLine ( surfaceArea ( b , s ) ) ; } }


"Program to find the time remaining for the day to complete | C # program to Number of pairs of lines having integer intersection points ; Function to find the remaining time ; Formula for total remaining minutes = 1440 - 60 h - m ; Remaining hours ; Remaining minutes ; Driver code ; Current time ; Get the remaining time"
Solution in C#:

using System ; class GFG { static void remainingTime ( int h , int m ) { int totalMin , hoursRemaining , minRemaining ; totalMin = 1440 - 60 * h - m ; hoursRemaining = totalMin / 60 ; minRemaining = totalMin % 60 ; Console . WriteLine ( hoursRemaining + " : : " + minRemaining ) ; } public static void Main ( ) { int h = 0 , m = 1 ; remainingTime ( h , m ) ; } }


"Program to find the value of P ( N + r ) for a polynomial of a degree N such that P ( i ) = 1 for 1 Ã ¢ â €°¤ i Ã ¢ â €°¤ N and P ( N + 1 ) = a | C # program for the above approach ; Function to calculate factorial of N ; Base Case ; Otherwise , recursively calculate the factorial ; Function to find the value of P ( n + r ) for polynomial P ( X ) ; Stores the value of k ; Store the required answer ; Iterate in the range [ 1 , N ] and multiply ( n + r - i ) with answer ; Add the constant value C as 1 ; Return the result ; Driver Code"
Solution in C#:

using System ; class GFG { static int fact ( int n ) { if ( n == 1 n == 0 ) return 1 ; else return n * fact ( n - 1 ) ; } static int findValue ( int n , int r , int a ) { int k = ( a - 1 ) / fact ( n ) ; int answer = k ; for ( int i = 1 ; i < n + 1 ; i ++ ) answer = answer * ( n + r - i ) ; answer = answer + 1 ; return answer ; } static public void Main ( ) { int N = 1 ; int A = 2 ; int R = 3 ; Console . Write ( ( findValue ( N , R , A ) ) ) ; } }


"Program to find the value of sin ( nÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬¦½ ÃƒÆ ’ Ã † â €™ Ãƒ ¢ Ã ¢ â € š ¬¹ ÃƒÆ ’ Ã ¢ â ‚¬¦ Ãƒ ¢ Ã ¢ â € š ¬ Ã … â € œ ) | C # Program to find the value of sin ( n ? ) ; This function use to calculate the binomial coefficient upto 15 ; use simple DP to find coefficient ; Function to find the value of cos ( n - theta ) ; find cosTheta from sinTheta ; store required answer ; use to toggle sign in sequence . ; Driver code"
Solution in C#:

using System ; class GFG { private static int MAX = 16 ; static long [ , ] nCr = new long [ MAX , MAX ] ; static void binomial ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { if ( j == 0 j == i ) nCr [ i , j ] = 1 ; else nCr [ i , j ] = nCr [ i - 1 , j ] + nCr [ i - 1 , j - 1 ] ; } } } static double findCosNTheta ( double sinTheta , int n ) { double cosTheta = Math . Sqrt ( 1 - sinTheta * sinTheta ) ; double ans = 0 ; long toggle = 1 ; for ( int i = 1 ; i <= n ; i += 2 ) { ans = ans + nCr [ n , i ] * Math . Pow ( cosTheta , n - i ) * Math . Pow ( sinTheta , i ) * toggle ; toggle = toggle * - 1 ; } return ans ; } public static void Main ( ) { binomial ( ) ; double sinTheta = 0.5 ; int n = 10 ; Console . Write ( findCosNTheta ( sinTheta , n ) ) ; } }


"Program to find the value of tan ( nÎ ˜ ) | C # program to find the value of cos ( n - theta ) ; This function use to calculate the binomial coefficient upto 15 ; use simple DP to find coefficient ; Function to find the value of ; store required answer ; use to toggle sign in sequence . ; calculate numerator ; calculate denominator ; Driver code"
Solution in C#:

using System ; public class GFG { private static int MAX = 16 ; static long [ , ] nCr = new long [ MAX , MAX ] ; static void binomial ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { if ( j == 0 j == i ) nCr [ i , j ] = 1 ; else nCr [ i , j ] = nCr [ i - 1 , j ] + nCr [ i - 1 , j - 1 ] ; } } } static double findTanNTheta ( double tanTheta , int n ) { double ans = 0 , numerator = 0 , denominator = 0 ; long toggle = 1 ; for ( int i = 1 ; i <= n ; i += 2 ) { numerator = numerator + nCr [ n , i ] * Math . Pow ( tanTheta , i ) * toggle ; toggle = toggle * - 1 ; } denominator = 1 ; toggle = - 1 ; for ( int i = 2 ; i <= n ; i += 2 ) { numerator = numerator + nCr [ n , i ] * Math . Pow ( tanTheta , i ) * toggle ; toggle = toggle * - 1 ; } ans = numerator / denominator ; return ans ; } public static void Main ( ) { binomial ( ) ; double tanTheta = 0.3 ; int n = 10 ; Console . Write ( findTanNTheta ( tanTheta , n ) ) ; } }


"Program to find third side of triangle using law of cosines | C # program to find third side of triangle using law of cosines ; Function to calculate cos value of angle c ; Converting degrees to radian ; Maps the sum along the series ; Holds the actual value of sin ( n ) ; Function to find third side ; Driver code ; function call"
Solution in C#:

using System ; class GFG { static float cal_cos ( float n ) { float accuracy = 0.0001f , x1 ; float denominator , cosx , cosval ; n = n * ( 3.142f / 180.0f ) ; x1 = 1 ; cosx = x1 ; cosval = ( float ) Math . Cos ( n ) ; int i = 1 ; do { denominator = 2 * i * ( 2 * i - 1 ) ; x1 = - x1 * n * n / denominator ; cosx = cosx + x1 ; i = i + 1 ; } while ( accuracy <= Math . Abs ( cosval - cosx ) ) ; return cosx ; } static float third_side ( int a , int b , float c ) { float angle = cal_cos ( c ) ; return ( float ) Math . Sqrt ( ( a * a ) + ( b * b ) - 2 * a * b * angle ) ; } public static void Main ( ) { float c = 49 ; int a = 5 , b = 8 ; Console . WriteLine ( Math . Round ( third_side ( a , b , c ) * 100000.0 ) / 100000.0 ) ; } }


"Program to find total number of edges in a Complete Graph | C # implementation to find the number of edges in a complete graph ; Function to find the total number of edges in a complete graph with N vertices ; Driver Code"
Solution in C#:

using System ; class GFG { static int totEdge ( int n ) { int result = 0 ; result = ( n * ( n - 1 ) ) / 2 ; return result ; } public static void Main ( ) { int n = 6 ; Console . Write ( totEdge ( n ) ) ; } }


"Program to find volume and surface area of pentagonal prism | C # program to find surface area and volume of the Pentagonal Prism ; function for surface area ; function for VOlume ; Driver Code"
Solution in C#:

using System ; class GFG { static float surfaceArea ( float a , float b , float h ) { return 5 * a * b + 5 * b * h ; } static float volume ( float b , float h ) { return ( 5 * b * h ) / 2 ; } public static void Main ( ) { float a = 5 ; float b = 3 ; float h = 7 ; Console . WriteLine ( " surface ▁ area ▁ = ▁ " + surfaceArea ( a , b , h ) + " , ▁ " ) ; Console . WriteLine ( " volume ▁ = ▁ " + volume ( b , h ) ) ; } }


"Program to find weighted median of a given array | C # program for the above approach ; Function to calculate weighted median ; Store pr of arr [ i ] and W [ i ] ; Sort the list of pr w . r . t . to their arr [ ] values ; If N is odd ; Traverse the set pr from left to right ; Update sums ; If sum becomes > 0.5 ; If N is even ; For lower median traverse the set pr from left ; Update sums ; When sum >= 0.5 ; For upper median traverse the set pr from right ; Update sums ; When sum >= 0.5 ; Driver code ; Given array arr [ ] ; Given weights W [ ] ; Function Call"
Solution in C#:

using System ; using System . Collections . Generic ; class GFG { static void weightedMedian ( int [ ] arr , float [ ] W ) { List < Tuple < int , float > > pr = new List < Tuple < int , float > > ( ) ; for ( int index = 0 ; index < arr . Length ; index ++ ) pr . Add ( new Tuple < int , float > ( arr [ index ] , W [ index ] ) ) ; pr . Sort ( ) ; if ( arr . Length % 2 != 0 ) { float sums = 0 ; foreach ( Tuple < int , float > element in pr ) { sums += element . Item2 ; if ( sums > 0.5 ) Console . WriteLine ( " The ▁ Weighted ▁ Median ▁ " + " is ▁ element ▁ " + element . Item1 ) ; } } else { float sums = 0 ; foreach ( Tuple < int , float > element in pr ) { sums += element . Item2 ; if ( sums >= 0.5 ) { Console . WriteLine ( " Lower ▁ Weighted ▁ Median ▁ " + " is ▁ element ▁ " + element . Item1 ) ; break ; } } sums = 0 ; for ( int index = pr . Count - 1 ; index >= 0 ; index -- ) { int element = pr [ index ] . Item1 ; float weight = pr [ index ] . Item2 ; sums += weight ; if ( sums >= 0.5 ) { Console . Write ( " Upper ▁ Weighted ▁ Median ▁ " + " is ▁ element ▁ " + element ) ; break ; } } } } static void Main ( ) { int [ ] arr = { 4 , 1 , 3 , 2 } ; float [ ] W = { 0.25f , 0.49f , 0.25f , 0.01f } ; weightedMedian ( arr , W ) ; } }


"Program to generate an array having convolution of two given arrays | C # program for the above approach ; Function to generate a convolution array of two given arrays ; Stores the size of arrays ; Stores the final array ; Traverse the two given arrays ; Update the convolution array ; Print the convolution array c [ ] ; Driver Code"
Solution in C#:

using System ; class GFG { static int MOD = 998244353 ; static void findConvolution ( int [ ] a , int [ ] b ) { int n = a . Length , m = b . Length ; int [ ] c = new int [ ( n + m - 1 ) ] ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { c [ i + j ] += ( a [ i ] * b [ j ] ) % MOD ; } } for ( int k = 0 ; k < c . Length ; ++ k ) { c [ k ] %= MOD ; Console . Write ( c [ k ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 2 , 3 , 4 } ; int [ ] B = { 5 , 6 , 7 , 8 , 9 } ; findConvolution ( A , B ) ; } }


"Program to get the Sum of series : 1 | C # program to get the sum of the series ; Function to get the series ; Computing sum of remaining n - 1 terms . ; Driver Code"
Solution in C#:

using System ; class GFG { static float Series ( double x , int n ) { double sum = 1 , term = 1 , fct = 1 ; double p = 1 , multi = 1 ; for ( int i = 1 ; i < n ; i ++ ) { fct = fct * multi * ( multi + 1 ) ; p = p * x * x ; term = ( - 1 ) * term ; multi += 2 ; sum = sum + ( term * p ) / fct ; } return ( float ) sum ; } public static void Main ( ) { double x = 9 ; int n = 10 ; Console . Write ( Series ( x , n ) ) ; } }


"Program to get the Sum of series : 1 | C # program to get the sum of the series ; Function to get the series ; Sum of n - 1 terms starting from 2 nd term ; Driver Code"
Solution in C#:

using System ; class GFG { static double Series ( double x , int n ) { double sum = 1 , term = 1 , fct , j , y = 2 , m ; int i ; for ( i = 1 ; i < n ; i ++ ) { fct = 1 ; for ( j = 1 ; j <= y ; j ++ ) { fct = fct * j ; } term = term * ( - 1 ) ; m = Math . Pow ( x , y ) / fct ; m = m * term ; sum = sum + m ; y += 2 ; } return sum ; } public static void Main ( ) { double x = 9 ; int n = 10 ; Console . Write ( Series ( x , n ) * 10000.0 / 10000.0 ) ; } }


"Program to implement ASCII lookup table | C # implementation for ASCII table lookup ; Function to convert decimal value to equivalent octal value ; Function to convert decimal value to equivalent hexadecimal value ; Function to convert decimal value to equivalent HTML value ; ASCII lookup table ; Implicit typecasting converts the character into it 's equivalent ASCII ; Driver Code"
Solution in C#:

using System ; class GeeksforGeeks { static int Octal ( int decima ) { int octal = 0 ; String temp = " " ; while ( decima > 0 ) { int remainder = decima % 8 ; temp = remainder + temp ; decima /= 8 ; } for ( int i = 0 ; i < temp . Length ; i ++ ) octal = ( octal * 10 ) + ( temp [ i ] - '0' ) ; return octal ; } static String Hexadecimal ( int decima ) { String hex = " " ; while ( decima > 0 ) { int remainder = decima % 16 ; if ( remainder >= 0 && remainder <= 9 ) hex = remainder + hex ; else hex = ( char ) ( ' A ' + remainder % 10 ) + hex ; decima /= 16 ; } return hex ; } static String HTML ( int decima ) { String html = " " ; html = html + decima ; html = " & # " + html + " ; " ; return html ; } static void ASCIIlookuptable ( char ch ) { int decima = ch ; Console . WriteLine ( " Octal ▁ value : ▁ " + Octal ( decima ) ) ; Console . WriteLine ( " Decimal ▁ value : ▁ " + decima ) ; Console . WriteLine ( " Hexadecimal ▁ value : ▁ " + Hexadecimal ( decima ) ) ; Console . Write ( " HTML ▁ value : ▁ " + HTML ( decima ) ) ; } public static void Main ( ) { char ch = ' @ ' ; ASCIIlookuptable ( ch ) ; } }


"Program to implement Collatz Conjecture | C # program to implement Collatz Conjecture ; Function to find if n reaches to 1 or not . ; If there is a cycle formed , we can 't reach 1. ; If n is odd then pass n = 3 n + 1 else n = n / 2 ; Wrapper over isToOneRec ( ) ; To store numbers visited using recursive calls . ; Driver code"
Solution in C#:

using System ; using System . Collections . Generic ; class GFG { static Boolean isToOneRec ( int n , HashSet < int > s ) { if ( n == 1 ) { return true ; } if ( s . Contains ( n ) ) { return false ; } return ( n % 2 == 1 ) ? isToOneRec ( 3 * n + 1 , s ) : isToOneRec ( n / 2 , s ) ; } static Boolean isToOne ( int n ) { HashSet < int > s = new HashSet < int > ( ) ; return isToOneRec ( n , s ) ; } public static void Main ( String [ ] args ) { int n = 5 ; if ( isToOne ( n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to implement Collatz Conjecture | C # program to implement Collatz Conjecture ; Function to find if n reaches to 1 or not . ; Return true if n is positive ; Drivers code"
Solution in C#:

using System ; class GFG { static bool isToOne ( int n ) { return ( n > 0 ) ; } public static void Main ( ) { int n = 5 ; if ( isToOne ( n ) == true ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }


"Program to implement Inverse Interpolation using Lagrange Formula | C # code for solving inverse interpolation ; Consider a structure to keep each pair of x and y together ; Function to calculate the inverse interpolation ; Initialize readonly x ; Calculate each term of the given formula ; Add term to readonly result ; Driver Code ; Sample dataset of 4 points Here we find the value of x when y = 4.5 ; Size of dataset ; Sample y value ; Using the Inverse Interpolation function to find the value of x when y = 4.5"
Solution in C#:

using System ; class GFG { class Data { public double x , y ; public Data ( double x , double y ) { this . x = x ; this . y = y ; } } ; static double inv_interpolate ( Data [ ] d , int n , double y ) { double x = 0 ; int i , j ; for ( i = 0 ; i < n ; i ++ ) { double xi = d [ i ] . x ; for ( j = 0 ; j < n ; j ++ ) { if ( j != i ) { xi = xi * ( y - d [ j ] . y ) / ( d [ i ] . y - d [ j ] . y ) ; } } x += xi ; } return x ; } public static void Main ( String [ ] args ) { Data [ ] d = { new Data ( 1.27 , 2.3 ) , new Data ( 2.25 , 2.95 ) , new Data ( 2.5 , 3.5 ) , new Data ( 3.6 , 5.1 ) } ; int n = 4 ; double y = 4.5 ; Console . Write ( " Value ▁ of ▁ x ▁ at ▁ y ▁ = ▁ 4.5 ▁ : ▁ { 0 : f5 } " , inv_interpolate ( d , n , y ) ) ; } }


"Program to implement Simpson 's 3/8 rule | C # Code to implement Simpson 's rule ; Given function to be integrated ; Function to perform calculations ; Calculates value till integral limit ; Driver program to test above function"
Solution in C#:

using System ; class GFG { static float func ( float x ) { return ( 1 / ( 1 + x * x ) ) ; } static float calculate ( float lower_limit , float upper_limit , int interval_limit ) { float interval_size = ( upper_limit - lower_limit ) / interval_limit ; float sum = func ( lower_limit ) + func ( upper_limit ) ; for ( int i = 1 ; i < interval_limit ; i ++ ) { if ( i % 3 == 0 ) sum = sum + 2 * func ( lower_limit + i * interval_size ) ; else sum = sum + 3 * func ( lower_limit + i * interval_size ) ; } return ( 3 * interval_size / 8 ) * sum ; } public static void Main ( ) { int interval_limit = 10 ; float lower_limit = 1 ; float upper_limit = 10 ; float integral_res = calculate ( lower_limit , upper_limit , interval_limit ) ; Console . WriteLine ( integral_res ) ; } }


"Program to implement standard deviation of grouped data | C # program to implement standard deviation of grouped data . ; Function to find mean of grouped data . ; Function to find standard deviation of grouped data . ; Formula to find standard deviation deviation of grouped data . ; Driver function . ; Declare and initialize the lower limit of interval . ; Declare and initialize the upper limit of interval . ; Calculating the size of array ."
Solution in C#:

using System ; class GFG { static float mean ( float [ ] mid , int [ ] freq , int n ) { float sum = 0 , freqSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + mid [ i ] * freq [ i ] ; freqSum = freqSum + freq [ i ] ; } return sum / freqSum ; } static float groupedSD ( float [ ] lower_limit , float [ ] upper_limit , int [ ] freq , int n ) { float [ ] mid = new float [ n ] ; float sum = 0 , freqSum = 0 , sd ; for ( int i = 0 ; i < n ; i ++ ) { mid [ i ] = ( lower_limit [ i ] + upper_limit [ i ] ) / 2 ; sum = sum + freq [ i ] * mid [ i ] * mid [ i ] ; freqSum = freqSum + freq [ i ] ; } sd = ( float ) Math . Sqrt ( ( sum - freqSum * mean ( mid , freq , n ) * mean ( mid , freq , n ) ) / ( freqSum - 1 ) ) ; return sd ; } public static void Main ( ) { float [ ] lower_limit = { 50 , 61 , 71 , 86 , 96 } ; float [ ] upper_limit = { 60 , 70 , 85 , 95 , 100 } ; int [ ] freq = { 9 , 7 , 9 , 12 , 8 } ; int n = lower_limit . Length ; Console . WriteLine ( groupedSD ( lower_limit , upper_limit , freq , n ) ) ; } }


"Program to implement standard error of mean | C # Program to implement standard error of mean . ; Function to find sample mean . ; loop to calculate sum of array elements . ; Function to calculate sample standard deviation . ; Function to calculate sample error . ; Formula to find sample error . ; Driver code"
Solution in C#:

using System ; class GFG { static float mean ( float [ ] arr , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; return sum / n ; } static float SSD ( float [ ] arr , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) ) ; return ( float ) Math . Sqrt ( sum / ( n - 1 ) ) ; } static float sampleError ( float [ ] arr , int n ) { return SSD ( arr , n ) / ( float ) Math . Sqrt ( n ) ; } public static void Main ( ) { float [ ] arr = { 78.53f , 79.62f , 80.25f , 81.05f , 83.21f , 83.46f } ; int n = arr . Length ; Console . Write ( sampleError ( arr , n ) ) ; } }


"Program to insert dashes between two adjacent odd digits in given Number | C # program to implement the above approach ; Function to check if char ch is odd or not ; Function to insert dash - between any 2 consecutive digit in string str ; Traverse the string character by character ; Compare every consecutive character with the odd value ; Print the resultant string ; Driver Code ; Given number in form of string ; Function call"
Solution in C#:

using System ; using System . Text ; class GFG { static bool checkOdd ( char ch ) { return ( ( ch - '0' ) & 1 ) != 0 ? true : false ; } static String Insert_dash ( String num_str ) { StringBuilder result_str = new StringBuilder ( num_str ) ; for ( int x = 0 ; x < num_str . Length - 1 ; x ++ ) { if ( checkOdd ( num_str [ x ] ) && checkOdd ( num_str [ x + 1 ] ) ) { result_str . Insert ( x + 1 , " - " ) ; num_str = result_str . ToString ( ) ; x ++ ; } } return result_str . ToString ( ) ; } public static void Main ( String [ ] args ) { String str = "1745389" ; Console . WriteLine ( Insert_dash ( str ) ) ; } }


"Program to perform a letter frequency attack on a monoalphabetic substitution cipher | C # program for the above approach ; Function to decrypt a monoalphabetic substitution cipher using the letter frequency attack ; Stores readonly 5 possible deciphered plaintext ; Store the frequency of each letter in cipher text ; Stores the frequency of each letter in cipher text in descending order ; Store which alphabet is used already ; Traverse the String S ; Copy the frequency array ; Stores the String formed from concatanating the english letters in the decreasing frequency in the english language ; Sort the array in descending order ; Itearate over the range [ 0 , 5 ] ; Iterate over the range [ 0 , 26 ] ; Store the numerical equivalent of letter at ith index of array letter_frequency ; Calculate the probable shift used in monoalphabetic cipher ; Temporary String to generate one plaintext at a time ; Generate the probable ith plaintext String using the shift calculated above ; Insert whitespaces as it is ; Shift the kth letter of the cipher by x ; Add the kth calculated / shifted letter to temporary String ; Print the generated 5 possible plaintexts ; Driver Code ; Given String ; Function Call"
Solution in C#:

 using System ; public class GFG { static void printString ( String S , int N ) { String [ ] plaintext = new String [ 5 ] ; int [ ] freq = new int [ 26 ] ; int [ ] freqSorted = new int [ 26 ] ; int [ ] Used = new int [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] != ' ▁ ' ) { freq [ S [ i ] - ' A ' ] ++ ; } } for ( int i = 0 ; i < 26 ; i ++ ) { freqSorted [ i ] = freq [ i ] ; } String T = " ETAOINSHRDLCUMWFGYPBVKJXQZ " ; Array . Sort ( freqSorted ) ; freqSorted = reverse ( freqSorted ) ; for ( int i = 0 ; i < 5 ; i ++ ) { int ch = - 1 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( freqSorted [ i ] == freq [ j ] && Used [ j ] == 0 ) { Used [ j ] = 1 ; ch = j ; break ; } } if ( ch == - 1 ) break ; int x = T [ i ] - ' A ' ; x = x - ch ; String curr = " " ; for ( int k = 0 ; k < N ; k ++ ) { if ( S [ k ] == ' ▁ ' ) { curr += ( char ) ' ▁ ' ; continue ; } int y = S [ k ] - ' A ' ; y += x ; if ( y < 0 ) y += 26 ; if ( y > 25 ) y -= 26 ; curr += ( char ) ( ' A ' + y ) ; } plaintext [ i ] = curr ; } for ( int i = 0 ; i < 5 ; i ++ ) { Console . Write ( plaintext [ i ] + "
 " ) ; } } static int [ ] reverse ( int [ ] a ) { int i , n = a . Length , t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } public static void Main ( String [ ] args ) { String S = " B ▁ TJNQMF ▁ NFTTBHF " ; int N = S . Length ; printString ( S , N ) ; } }


"Program to print Arithmetic Progression series | C # Program to print an arithmetic progression series ; Printing AP by simply adding d to previous term . ; Driver code ; starting number ; Common difference ; N th term to be find"
Solution in C#:

using System ; class GFG { static void printAP ( int a , int d , int n ) { int curr_term ; curr_term = a ; for ( int i = 1 ; i <= n ; i ++ ) { Console . Write ( curr_term + " ▁ " ) ; curr_term += d ; } } public static void Main ( ) { int a = 2 ; int d = 1 ; int n = 5 ; printAP ( a , d , n ) ; } }


"Program to print Collatz Sequence | C # program to print Collatz sequence ; We simply follow steps while we do not reach 1 ; If n is odd ; If even ; Print 1 at the end ; Driver code"
Solution in C#:

using System ; class GFG { static void printCollatz ( int n ) { while ( n != 1 ) { Console . Write ( n + " ▁ " ) ; if ( ( n & 1 ) == 1 ) n = 3 * n + 1 ; else n = n / 2 ; } Console . Write ( n ) ; } static void Main ( ) { printCollatz ( 6 ) ; } }


"Program to print GP ( Geometric Progression ) | C # program to print GP . ; function to print GP ; Driver code ; starting number ; Common ratio ; N th term to be find"
Solution in C#:

using System ; class GFG { static void printGP ( int a , int r , int n ) { int curr_term ; for ( int i = 0 ; i < n ; i ++ ) { curr_term = a * ( int ) Math . Pow ( r , i ) ; Console . Write ( curr_term + " ▁ " ) ; } } public static void Main ( ) { int a = 2 ; int r = 3 ; int n = 5 ; printGP ( a , r , n ) ; } }


"Program to print a Hollow Triangle inside a Triangle | C # implementation of the above approach ; Function to print the pattern ; Loop for rows ; Loop for column ; For printing equal sides of outer triangle ; For printing equal sides of inner triangle ; For printing base of both triangle ; For spacing between the triangle ; Driver Code"
Solution in C#:

 using System ; class GFG { static void printPattern ( int n ) { int i , j ; for ( i = 1 ; i <= n ; i ++ ) { for ( j = 1 ; j < 2 * n ; j ++ ) { if ( j == ( n - i + 1 ) || j == ( n + i - 1 ) ) { Console . Write ( " * ▁ " ) ; } else if ( ( i >= 4 && i <= n - 4 ) && ( j == n - i + 4 j == n + i - 4 ) ) { Console . Write ( " * ▁ " ) ; } else if ( i == n || ( i == n - 4 && j >= n - ( n - 2 * 4 ) && j <= n + n - 2 * 4 ) ) { Console . Write ( " * ▁ " ) ; } else { Console . Write ( " ▁ " + " ▁ " ) ; } } Console . Write ( "
 " ) ; } } public static void Main ( String [ ] args ) { int N = 9 ; printPattern ( N ) ; } }


"Program to print a string in vertical zigzag manner | C # program for the above approach ; Function to print any string in zigzag fashion ; Store the gap between the major columns ; Traverse through rows ; Store the step value for each row ; Iterate in the range [ 1 , N - 1 ] ; Print the character ; Print the spaces before character s [ j + step ] ; Print the character ; Print the spaces after character after s [ j + step ] ; Print the spaces for first and last rows ; Driver Code ; Given Input ; Function Call"
Solution in C#:

using System ; using System . Collections . Generic ; class GFG { static void zigzag ( string s , int rows ) { int interval = 2 * rows - 2 ; for ( int i = 0 ; i < rows ; i ++ ) { int step = interval - 2 * i ; for ( int j = i ; j < s . Length ; j = j + interval ) { Console . Write ( s [ j ] ) ; if ( step > 0 && step < interval && step + j < s . Length ) { for ( int k = 0 ; k < ( interval - rows - i ) ; k ++ ) Console . Write ( " ▁ " ) ; Console . Write ( s [ j + step ] ) ; for ( int k = 0 ; k < i - 1 ; k ++ ) Console . Write ( " ▁ " ) ; } else { for ( int k = 0 ; k < ( interval - rows ) ; k ++ ) Console . Write ( " ▁ " ) ; } } Console . WriteLine ( ) ; } } public static void Main ( ) { string s = "123456789ABCDEFGHIJKLM " + " NOPQRSTUVWXYZabcdefghi " + " jklmnopqrstuvwxyz " ; int rows = 9 ; zigzag ( s , rows ) ; } }


"Program to print all palindromes in a given range | C # Program to print all palindromes in a given range ; A function to check if n is palindrome ; Find reverse of n ; If n and rev are same , then n is palindrome ; prints palindrome between min and max ; Driver Code"
Solution in C#:

using System ; class GFG { public static int isPalindrome ( int n ) { int rev = 0 ; for ( int i = n ; i > 0 ; i /= 10 ) { rev = rev * 10 + i % 10 ; } return ( n == rev ) ? 1 : 0 ; } public static void countPal ( int min , int max ) { for ( int i = min ; i <= max ; i ++ ) { if ( isPalindrome ( i ) == 1 ) { Console . Write ( i + " ▁ " ) ; } } } public static void Main ( string [ ] args ) { countPal ( 100 , 2000 ) ; } }


"Program to print all substrings of a given string | C # program for the above approach ; finding the length of the string ; outermost for loop this is for the selection of starting point ; 2 nd for loop is for selection of ending point ; 3 rd loop is for printing from starting point to ending point ; changing the line after printing from starting point to ending point ; Driver Code ; calling method for printing substring"
Solution in C#:

using System ; public class GFG { public static void printSubstrings ( String str ) { int n = str . Length ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { for ( int k = i ; k <= j ; k ++ ) { Console . Write ( str [ k ] ) ; } Console . WriteLine ( ) ; } } } public static void Main ( String [ ] args ) { String str = " abcd " ; printSubstrings ( str ) ; } }


"Program to print all substrings of a given string | C # program to print all possible subStrings of a given String without checking for duplication . ; Function to print all ( n * ( n + 1 ) ) / 2 subStrings of a given String s of length n . ; Fix start index in outer loop . Reveal new character in inner loop till end of String . Print till - now - formed String . ; Driver code"
Solution in C#:

using System ; class GFG { public static void printAllSubStrings ( String s , int n ) { for ( int i = 0 ; i < n ; i ++ ) { char [ ] temp = new char [ n - i + 1 ] ; int tempindex = 0 ; for ( int j = i ; j < n ; j ++ ) { temp [ tempindex ++ ] = s [ j ] ; temp [ tempindex ] = ' \0' ; Console . WriteLine ( temp ) ; } } } public static void Main ( ) { String s = " Geeky " ; printAllSubStrings ( s , s . Length ) ; } }


"Program to print all substrings of a given string | C # program to print all possible substrings of a given string ; Function to print all sub strings ; Pick starting point ; Pick ending point ; Print characters from current starting point to current ending point . ; Driver program to test above function"
Solution in C#:

using System ; public class GFG { static void subString ( string str , int n ) { for ( int len = 1 ; len <= n ; len ++ ) { for ( int i = 0 ; i <= n - len ; i ++ ) { int j = i + len - 1 ; for ( int k = i ; k <= j ; k ++ ) Console . Write ( str [ k ] ) ; Console . WriteLine ( ) ; } } } static public void Main ( ) { string str = " abc " ; subString ( str , str . Length ) ; } }


"Program to print all substrings of a given string | C # program to print all substrings of a string ; Function to print all substring ; Pick starting point in outer loop and lengths of different strings for a given starting point ; Driver code"
Solution in C#:

using System ; public class GFG { public static void SubString ( String str , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 1 ; j <= n - i ; j ++ ) Console . WriteLine ( str . Substring ( i , j ) ) ; } public static void Main ( ) { String str = " abcd " ; SubString ( str , str . Length ) ; } }


"Program to print an array in Pendulum Arrangement with constant space | C # implementation of the approach ; Function to print the Pendulum arrangement of the given array ; Sort the array sort ( arr , arr + n ) ; ; pos stores the index of the last element of the array ; odd stores the last odd index in the array ; Move all odd index positioned elements to the right ; Shift the elements by one position from odd to pos ; Reverse the element from 0 to ( n - 1 ) / 2 ; Printing the pendulum arrangement ; Driver code"
Solution in C#:

using System ; class GFG { static void pendulumArrangement ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int odd , temp , p , pos ; pos = n - 1 ; if ( n % 2 == 0 ) odd = n - 1 ; else odd = n - 2 ; while ( odd > 0 ) { temp = arr [ odd ] ; p = odd ; while ( p != pos ) { arr [ p ] = arr [ p + 1 ] ; p ++ ; } arr [ p ] = temp ; odd = odd - 2 ; pos = pos - 1 ; } int start = 0 , end = ( n - 1 ) / 2 ; for ( ; start < end ; start ++ , end -- ) { temp = arr [ start ] ; arr [ start ] = arr [ end ] ; arr [ end ] = temp ; } for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 11 , 2 , 4 , 55 , 6 , 8 } ; int n = arr . Length ; pendulumArrangement ( arr , n ) ; } }


"Program to print an array in Pendulum Arrangement | C # program for pendulum arrangement of numbers ; Prints pendulum arrangement of arr [ ] ; sorting the elements ; Auxiliary array to store output ; calculating the middle index ; storing the minimum element in the middle i is index for output array and j is for input array . ; adjustment for when no . of elements is even ; Printing the pendulum arrangement ; Driver code ; input Array ; calling pendulum function"
Solution in C#:

using System ; class Test { static void pendulumArrangement ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int [ ] op = new int [ n ] ; int mid = ( n - 1 ) / 2 ; int j = 1 , i = 1 ; op [ mid ] = arr [ 0 ] ; for ( i = 1 ; i <= mid ; i ++ ) { op [ mid + i ] = arr [ j ++ ] ; op [ mid - i ] = arr [ j ++ ] ; } if ( n % 2 == 0 ) op [ mid + i ] = arr [ j ] ; Console . Write ( " Pendulum ▁ arrangement : " ) ; for ( i = 0 ; i < n ; i ++ ) Console . Write ( op [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int [ ] arr = { 14 , 6 , 19 , 21 , 12 } ; pendulumArrangement ( arr , arr . Length ) ; } }


"Program to print characters present at prime indexes in a given string | C # Program to print Characters at Prime index in a given String ; Corner case ; Check from 2 to n - 1 ; Function to print character at prime index ; Loop to check if index prime or not ; Driver code"
Solution in C#:

using System ; class GFG { static bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } static void prime_index ( string input ) { int n = input . Length ; for ( int i = 2 ; i <= n ; i ++ ) if ( isPrime ( i ) ) Console . Write ( input [ i - 1 ] ) ; } public static void Main ( ) { string input = " GeeksforGeeks " ; prime_index ( input ) ; } }


"Program to print factors of a number in pairs | C # program to print prime factors in pairs . ; Driver code"
Solution in C#:

 using System ; public class GEE { static void printPFsInPairs ( int n ) { for ( int i = 1 ; i * i <= n ; i ++ ) if ( n % i == 0 ) Console . Write ( i + " * " + n / i + "
 " ) ; } public static void Main ( ) { int n = 24 ; printPFsInPairs ( n ) ; } }


"Program to print first n Fibonacci Numbers | Set 1 | C # program to print first n Fibonacci Numbers ; Method to print first n Fibonacci Numbers ; Driver Code"
Solution in C#:

using System ; class Test { static void printFibonacciNumbers ( int n ) { int f1 = 0 , f2 = 1 , i ; if ( n < 1 ) return ; Console . Write ( f1 + " ▁ " ) ; for ( i = 1 ; i < n ; i ++ ) { Console . Write ( f2 + " ▁ " ) ; int next = f1 + f2 ; f1 = f2 ; f2 = next ; } } public static void Main ( ) { printFibonacciNumbers ( 7 ) ; } }


"Program to print multiplication table of a number | C # program to print table over given range . ; Driver code ; Change here to change input number ; Change here to change result"
Solution in C#:

 using System ; class GFG { public static void Main ( ) { int n = 8 ; int range = 12 ; for ( int i = 1 ; i <= range ; ++ i ) Console . Write ( n + " ▁ * ▁ " + i + " ▁ = ▁ " + n * i + "
 " ) ; } }


"Program to print non square numbers | C # program to print first n non - square numbers . ; Function to check perfect square ; function to print all non square number ; variable which stores the count ; not perfect square ; Driver code"
Solution in C#:

using System ; class GFG { static bool isPerfectSquare ( int n ) { if ( n < 0 ) return false ; double root = Math . Round ( ( double ) ( Math . Sqrt ( n ) ) ) ; return n == root * root ; } static void printnonsquare ( int n ) { int count = 0 ; for ( int i = 1 ; count < n ; ++ i ) { if ( ! isPerfectSquare ( i ) ) { Console . Write ( i + " ▁ " ) ; count ++ ; } } } static public void Main ( ) { int n = 10 ; printnonsquare ( n ) ; } }


"Program to print non square numbers | C # program to print first n non - square numbers . ; Print curr_count numbers . curr_count is current gap between two square numbers . ; skip a square number . ; Count of next non - square numbers is next even number . ; Driver code"
Solution in C#:

using System ; class GFG { static void printNonSquare ( int n ) { int curr_count = 2 , num = 2 , count = 0 ; while ( count < n ) { for ( int i = 0 ; i < curr_count && count < n ; i ++ ) { Console . Write ( num + " ▁ " ) ; count ++ ; num ++ ; } num ++ ; curr_count += 2 ; } } static public void Main ( ) { int n = 10 ; printNonSquare ( n ) ; } }


"Program to print non square numbers | C # program to print first n non - square numbers . ; Returns n - th non - square number . ; loop to print non squares below n ; Driver code"
Solution in C#:

using System ; class GFG { static int nonsquare ( int n ) { return n + ( int ) ( 0.5 + ( Math . Sqrt ( n ) ) ) ; } static void printNonSquare ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) Console . Write ( nonsquare ( i ) + " ▁ " ) ; } public static void Main ( ) { int n = 10 ; printNonSquare ( n ) ; } }


"Program to print numbers from N to 1 in reverse order | C # program to print all numbers between 1 to N in reverse order ; Recursive function to print from N to 1 ; Driver code"
Solution in C#:

using System ; class GFG { static void PrintReverseOrder ( int N ) { for ( int i = N ; i > 0 ; i -- ) Console . Write ( i + " ▁ " ) ; } public static void Main ( String [ ] args ) { int N = 5 ; PrintReverseOrder ( N ) ; } }


"Program to print numbers from N to 1 in reverse order | C # program to print all numbers between 1 to N in reverse order ; Recursive function to print from N to 1 ; If N is less than 1 then return static void function ; Recursive call of the function ; Driver code"
Solution in C#:

using System ; class GFG { static void PrintReverseOrder ( int N ) { if ( N <= 0 ) { return ; } else { Console . Write ( N + " ▁ " ) ; PrintReverseOrder ( N - 1 ) ; } } public static void Main ( ) { int N = 5 ; PrintReverseOrder ( N ) ; } }


"Program to print pentatope numbers upto Nth term | C # program to generate Pentatope Number series ; Function to generate nth tetrahedral number ; Function to print pentatope number series upto nth term . ; Initialize prev as 0. It store the sum of all previously generated pentatope numbers ; Loop to print pentatope series ; Find ith tetrahedral number ; Add ith tetrahedral number to sum of all previously generated tetrahedral number to get ith pentatope number ; Update sum of all previously generated tetrahedral number ; Driver code ; Function call to print pentatope number series"
Solution in C#:

using System ; public class GFG { static int findTetrahedralNumber ( int n ) { return ( ( n * ( n + 1 ) * ( n + 2 ) ) / 6 ) ; } static void printSeries ( int n ) { int prev = 0 ; int curr ; for ( int i = 1 ; i <= n ; i ++ ) { curr = findTetrahedralNumber ( i ) ; curr = curr + prev ; Console . Write ( curr + " ▁ " ) ; prev = curr ; } } static public void Main ( ) { int n = 10 ; printSeries ( n ) ; } }


"Program to print pentatope numbers upto Nth term | C # program to print Pentatope number series . ; Function to print pentatope series up to nth term ; Loop to print pentatope number series ; calculate and print ith pentatope number ; Driver code ; Function call to print pentatope number series"
Solution in C#:

using System ; public class GFG { static void printSeries ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { int num = ( i * ( i + 1 ) * ( i + 2 ) * ( i + 3 ) / 24 ) ; Console . Write ( num + " ▁ " ) ; } } static public void Main ( ) { int n = 10 ; printSeries ( n ) ; } }


"Program to print tetrahedral numbers upto Nth term | C # program to generate series of tetrahedral numbers ; function to print tetrahedral number series up to n ; loop to print series ; Calculate and print ith tetrahedral number ; Driver code ; function call to print series"
Solution in C#:

using System ; public class GFG { static void printSeries ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { int num = i * ( i + 1 ) * ( i + 2 ) / 6 ; Console . Write ( num + " ▁ " ) ; } } static public void Main ( ) { int n = 10 ; printSeries ( n ) ; } }


"Program to print tetrahedral numbers upto Nth term | C # program to generate tetrahedral number series ; function to generate nth triangular number ; function to print tetrahedral number series up to n ; Initialize prev as 0. It store the sum of all previously generated triangular number ; Loop to print series ; Find ithh triangular number ; Add ith triangular number to sum of all previously generated triangular number to get ith tetrahedral number ; Update sum of all previously generated triangular number ; Driver code ; function call to print series"
Solution in C#:

using System ; public class GFG { static long findTriangularNumber ( int n ) { return ( n * ( n + 1 ) ) / 2 ; } static void printSeries ( int n ) { long prev = 0 ; long curr ; for ( int i = 1 ; i <= n ; i ++ ) { curr = findTriangularNumber ( i ) ; curr = curr + prev ; Console . Write ( curr + " ▁ " ) ; prev = curr ; } } static public void Main ( ) { int n = 10 ; printSeries ( n ) ; } }


"Program to print the Sum of series | C # program to find SUM upto N - th term of the series : - 1 , 2 , 11 , 26 , 47 , 74 , ... . . ; calculate Nth term of series ; Driver Code ; Get the value of N ; Get the sum of the series"
Solution in C#:

using System ; class GFG { static int findSum ( int N ) { return ( N * ( N + 1 ) * ( 2 * N - 5 ) + 4 * N ) / 2 ; } static public void Main ( ) { int N = 3 ; Console . Write ( findSum ( N ) ) ; } }


"Program to print the given digit in words | C # implementation of the above approach ; Function to return the word of the corresponding digit ; Switch block to check for each digit c ; For digit 0 ; For digit 1 ; For digit 2 ; For digit 3 ; For digit 4 ; For digit 5 ; For digit 6 ; For digit 7 ; For digit 8 ; For digit 9 ; Function to iterate through every digit in the given number ; Finding each digit of the number ; Print the digit in words ; Driver code"
Solution in C#:

using System ; class GFG { static void printValue ( char digit ) { switch ( digit ) { case '0' : Console . Write ( " Zero ▁ " ) ; break ; case '1' : Console . Write ( " One ▁ " ) ; break ; case '2' : Console . Write ( " Two ▁ " ) ; break ; case '3' : Console . Write ( " Three ▁ " ) ; break ; case '4' : Console . Write ( " Four ▁ " ) ; break ; case '5' : Console . Write ( " Five ▁ " ) ; break ; case '6' : Console . Write ( " Six ▁ " ) ; break ; case '7' : Console . Write ( " Seven ▁ " ) ; break ; case '8' : Console . Write ( " Eight ▁ " ) ; break ; case '9' : Console . Write ( " Nine ▁ " ) ; break ; } } static void printWord ( string N ) { int i , length = N . Length ; for ( i = 0 ; i < length ; i ++ ) { printValue ( N [ i ] ) ; } } public static void Main ( ) { string N = "123" ; printWord ( N ) ; } }


"Program to print the initials of a name with the surname | C # program to print the initials of a name with the surname ; to remove any leading or trailing spaces ; to store extracted words ; forming the word ; when space is encountered it means the name is completed and thereby extracted ; printing the first letter of the name in capital letters ; for the surname , we have to print the entire surname and not just the initial string " t " has the surname now ; first letter of surname in capital letter ; rest of the letters in small ; printing surname ; Driver Code"
Solution in C#:

using System ; class Initials { public static void printInitials ( string str ) { int len = str . Length ; str = str . Trim ( ) ; String t = " " ; for ( int i = 0 ; i < len ; i ++ ) { char ch = str [ i ] ; if ( ch != ' ▁ ' ) { t = t + ch ; } else { Console . Write ( Char . ToUpper ( t [ 0 ] ) + " . ▁ " ) ; t = " " ; } } string temp = " " ; for ( int j = 0 ; j < t . Length ; j ++ ) { if ( j == 0 ) temp = temp + Char . ToUpper ( t [ 0 ] ) ; else temp = temp + Char . ToLower ( t [ j ] ) ; } Console . WriteLine ( temp ) ; } public static void Main ( ) { string str = " ishita ▁ bhuiya " ; printInitials ( str ) ; } }


"Program to print the pattern 1020304017018019020 * * 50607014015016 * * * * 809012013 * * * * * * 10011. . . | C # implementation to print the given pattern ; Function to find the sum of N integers from 1 to N ; Function to print the given pattern ; Iterate over [ 0 , N - 1 ] ; Sub - Pattern - 1 ; Sub - Pattern - 2 ; Count the number of element in rows and sub - pattern 2 and 3 will have same rows ; Increment Val to print the series 1 , 2 , 3 , 4 , 5 ... ; Finally , add the ( N - 1 ) th element i . e . , 5 and increment it by 1 ; Initial is used to give the initial value of the row in Sub - Pattern 3 ; Sub - Pattern 3 ; Skip printing zero at the last ; Driver code ; Given N ; Function call"
Solution in C#:

using System ; class GFG { static int sum ( int n ) { return n * ( n - 1 ) / 2 ; } static void BSpattern ( int N ) { int Val = 0 , Pthree = 0 , cnt = 0 , initial = - 1 ; String s = " * * " ; for ( int i = 0 ; i < N ; i ++ ) { cnt = 0 ; if ( i > 0 ) { Console . Write ( s ) ; s += " * * " ; } for ( int j = i ; j < N ; j ++ ) { if ( i > 0 ) { cnt ++ ; } Console . Write ( ++ Val ) ; Console . Write ( "0" ) ; } if ( i == 0 ) { int Sumbeforelast = sum ( Val ) * 2 ; Pthree = Val + Sumbeforelast + 1 ; initial = Pthree ; } initial = initial - cnt ; Pthree = initial ; for ( int k = i ; k < N ; k ++ ) { Console . Write ( Pthree ++ ) ; if ( k != N - 1 ) { Console . Write ( "0" ) ; } } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int N = 5 ; BSpattern ( N ) ; } }


"Program to print the series 1 , 9 , 17 , 33 , 49 , 73 , 97. . . till N terms | C # implementation of the above approach ; Function to print the series ; Generate the ith term and print it ; Driver Code"
Solution in C#:

using System ; class GFG { static void printSeries ( int N ) { int ith_term = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { ith_term = i % 2 == 0 ? 2 * i * i + 1 : 2 * i * i - 1 ; Console . Write ( ith_term + " , ▁ " ) ; } } public static void Main ( ) { int N = 7 ; printSeries ( N ) ; } }


"Program to print the series 2 , 15 , 41 , 80 , 132 , 197 … till N terms | C # implementation to print the given with the given Nth term ; Function to print the series ; Generate the ith term and ; Driver Code"
Solution in C#:

using System ; class GFG { static void printSeries ( int N ) { int ith_term = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { ith_term = ( 13 * i * ( i - 1 ) ) / 2 + 2 ; Console . Write ( ith_term + " , ▁ " ) ; } } public static void Main ( String [ ] args ) { int N = 7 ; printSeries ( N ) ; } }


"Program to print the sum of the given nth term | C # program to illustrate ... Summation of series ; function to calculate sum of series ; Sum of n terms is n ^ 2 ; Driver code"
Solution in C#:

using System ; class GFG { static int summingSeries ( long n ) { return ( int ) Math . Pow ( n , 2 ) ; } public static void Main ( ) { int n = 100 ; Console . Write ( " The ▁ sum ▁ of ▁ n ▁ term ▁ is : ▁ " + summingSeries ( n ) ) ; } }