"Program to calculate the number of odd days in given number of years | C # implementation of the approach ; Function to return the count of odd days ; Count of years divisible by 100 and 400 ; Every 4 th year is a leap year ; Every 100 th year is divisible by 4 but is not a leap year ; Every 400 th year is divisible by 100 but is a leap year ; Total number of extra days ; modulo ( 7 ) for final answer ; Driver code ; Number of days"
Solution in C#:

using System ; class GFG { static int oddDays ( int N ) { int hund1 = N / 100 ; int hund4 = N / 400 ; int leap = N >> 2 ; int ord = N - leap ; if ( hund1 > 0 ) { ord += hund1 ; leap -= hund1 ; } if ( hund4 > 0 ) { ord -= hund4 ; leap += hund4 ; } int days = ord + leap * 2 ; int odd = days % 7 ; return odd ; } static void Main ( ) { int N = 100 ; Console . WriteLine ( oddDays ( N ) ) ; } }


"Program to calculate the value of sin ( x ) and cos ( x ) using Expansion | C # code for implementing cos function ; Function for calculation ; Converting degrees to radian ; maps the sum along the series ; holds the actual value of sin ( n ) ; Main function"
Solution in C#:

using System ; class GFG { static void cal_cos ( float n ) { float accuracy = ( float ) 0.0001 , x1 , denominator , cosx , cosval ; n = n * ( float ) ( 3.142 / 180.0 ) ; 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 <= cosval - cosx ) ; Console . WriteLine ( cosx ) ; } static void Main ( ) { float n = 30 ; cal_cos ( n ) ; } }


"Program to calculate value of nCr | C # program To calculate The Value Of nCr ; Returns factorial of n ; Driver code"
Solution in C#:

using System ; class GFG { static int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } static int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } public static void Main ( ) { int n = 5 , r = 3 ; Console . Write ( nCr ( n , r ) ) ; } }


"Program to calculate volume of Ellipsoid | C # program to find the volume of Ellipsoid . ; Function to find the volume ; Driver Code"
Solution in C#:

using System ; class GfG { public static float volumeOfEllipsoid ( float r1 , float r2 , float r3 ) { float pi = ( float ) 3.14 ; return ( float ) 1.33 * pi * r1 * r2 * r3 ; } public static void Main ( ) { float r1 = ( float ) 2.3 , r2 = ( float ) 3.4 , r3 = ( float ) 5.7 ; Console . WriteLine ( " volume ▁ of ▁ ellipsoid ▁ is ▁ : ▁ " + volumeOfEllipsoid ( r1 , r2 , r3 ) ) ; } }


"Program to calculate volume of Octahedron | C # Program to calculate volume of Octahedron ; Driver Function ; utility Function"
Solution in C#:

using System ; class GFG { public static void Main ( ) { double side = 3 ; Console . Write ( " Volume ▁ of ▁ octahedron ▁ = ▁ " ) ; Console . WriteLine ( vol_of_octahedron ( side ) ) ; } static double vol_of_octahedron ( double side ) { return ( ( side * side * side ) * ( Math . Sqrt ( 2 ) / 3 ) ) ; } }


"Program to check Involutory Matrix | C # Program to implement involutory matrix . ; Function for matrix multiplication . ; Function to check involutory matrix . ; multiply function call . ; Driver function . ; Function call . If function return true then if part will execute otherwise else part will execute ."
Solution in C#:

using System ; class GFG { static int N = 3 ; static void multiply ( int [ , ] mat , int [ , ] res ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { res [ i , j ] = 0 ; for ( int k = 0 ; k < N ; k ++ ) res [ i , j ] += mat [ i , k ] * mat [ k , j ] ; } } } static bool InvolutoryMatrix ( int [ , ] mat ) { int [ , ] res = new int [ N , N ] ; multiply ( mat , res ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i == j && res [ i , j ] != 1 ) return false ; if ( i != j && res [ i , j ] != 0 ) return false ; } } return true ; } public static void Main ( ) { int [ , ] mat = { { 1 , 0 , 0 } , { 0 , - 1 , 0 } , { 0 , 0 , - 1 } } ; if ( InvolutoryMatrix ( mat ) ) Console . WriteLine ( " Involutory ▁ Matrix " ) ; else Console . WriteLine ( " Not ▁ Involutory ▁ Matrix " ) ; } }


"Program to check Plus Perfect Number | C # implementation to check if the number is plus perfect or not ; function to check plus perfect number ; calculating number of digits ; calculating plus perfect number ; checking whether number is plus perfect or not ; Driver program"
Solution in C#:

using System ; class GFG { static bool checkplusperfect ( int x ) { int temp = x ; int n = 0 ; while ( x != 0 ) { x /= 10 ; n ++ ; } x = temp ; int sum = 0 ; while ( x != 0 ) { sum += ( int ) Math . Pow ( x % 10 , n ) ; x /= 10 ; } return ( sum == temp ) ; } public static void Main ( ) { int x = 9474 ; if ( checkplusperfect ( x ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }


"Program to check diagonal matrix and scalar matrix | Program to check matrix is diagonal matrix or not . ; Function to check matrix is diagonal matrix or not . ; condition to check other elements except main diagonal are zero or not . ; Driver function"
Solution in C#:

using System ; class GFG { static int N = 4 ; static bool isDiagonalMatrix ( int [ , ] mat ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( ( i != j ) && ( mat [ i , j ] != 0 ) ) return false ; return true ; } public static void Main ( ) { int [ , ] mat = { { 4 , 0 , 0 , 0 } , { 0 , 7 , 0 , 0 } , { 0 , 0 , 5 , 0 } , { 0 , 0 , 0 , 1 } } ; if ( isDiagonalMatrix ( mat ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }


"Program to check diagonal matrix and scalar matrix | Program to check matrix is scalar matrix or not . ; Function to check matrix is scalar matrix or not . ; Check all elements except main diagonal are zero or not . ; Check all diagonal elements are same or not . ; Driver function ; Function call"
Solution in C#:

using System ; class GFG { static int N = 4 ; static bool isScalarMatrix ( int [ , ] mat ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( ( i != j ) && ( mat [ i , j ] != 0 ) ) return false ; for ( int i = 0 ; i < N - 1 ; i ++ ) if ( mat [ i , i ] != mat [ i + 1 , i + 1 ] ) return false ; return true ; } public static void Main ( ) { int [ , ] mat = { { 2 , 0 , 0 , 0 } , { 0 , 2 , 0 , 0 } , { 0 , 0 , 2 , 0 } , { 0 , 0 , 0 , 2 } } ; if ( isScalarMatrix ( mat ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }


"Program to check if N is a Centered Cubic Number | C # program to check if N is a centered cubic number ; Function to check if N is a centered cubic number ; Iterating from 1 ; Infinite loop ; Finding ith_term ; Checking if the number N is a centered cube number ; If ith_term > N then N is not a centered cube number ; Incrementing i ; Driver code ; Function call"
Solution in C#:

using System ; class GFG { static Boolean isCenteredcube ( int N ) { int i = 1 ; while ( true ) { int ith_term = ( 2 * i + 1 ) * ( i * i + i + 1 ) ; if ( ith_term == N ) { return true ; } if ( ith_term > N ) { return false ; } i ++ ; } } public static void Main ( ) { int N = 9 ; if ( isCenteredcube ( N ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }


"Program to check if N is a Centered Decagonal Number | C # implementation to check that a number is a centered decagonal number or not ; Function to check that the number is a centered decagonal number ; Condition to check if the number is a centered decagonal number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isCentereddecagonal ( int N ) { double n = ( 5 + Math . Sqrt ( 20 * N + 5 ) ) / 10 ; return ( n - ( int ) n ) == 0 ; } static public void Main ( ) { int n = 11 ; if ( isCentereddecagonal ( n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Centered Octadecagonal number | C # implementation to check that a number is a centered octadecagonal number or not ; Function to check that the number is a centered octadecagonal number ; Implement the formula generated ; Condition to check if the number is a Centered octadecagonal number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isCenteredOctadecagonal ( int N ) { double n = ( 9 + Math . Sqrt ( 36 * N + 45 ) ) / 18 ; return ( n - ( int ) n ) == 0 ; } static public void Main ( ) { int n = 19 ; if ( isCenteredOctadecagonal ( n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Centered Pentagonal Number or not | C # program for the above approach ; Function to check if number N is a centered pentagonal number ; Condition to check if N is a centered pentagonal number ; Driver Code ; Given number ; Function call"
Solution in C#:

using System ; class GFG { static bool isCenteredpentagonal ( int N ) { float n = ( float ) ( ( 5 + Math . Sqrt ( 40 * N - 15 ) ) / 10 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( string [ ] args ) { int N = 6 ; if ( isCenteredpentagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Centered Tridecagonal Number | C # program for the above approach ; Function to check if the number N is a centered tridecagonal number ; Condition to check if the N is a centered tridecagonal number ; Driver Code ; Given Number ; Function call"
Solution in C#:

using System ; class GFG { static bool isCenteredtridecagonal ( int N ) { float n = ( float ) ( ( 13 + Math . Sqrt ( 104 * N + 65 ) ) / 26 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( string [ ] args ) { int N = 14 ; if ( isCenteredtridecagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Centered heptagonal number | C # implementation to check that a number is a centered heptagonal number or not ; Function to check that the number is a centered heptagonal number ; Condition to check if the number is a centered heptagonal number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isCenteredheptagonal ( int N ) { double n = ( 7 + Math . Sqrt ( 56 * N - 7 ) ) / 14 ; return ( n - ( int ) n ) == 0 ; } static public void Main ( ) { int n = 8 ; if ( isCenteredheptagonal ( n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Centered nonadecagonal number | C # implementation to check that a number is a Centered nonadecagonal number or not ; Function to check that the number is a Centered nonadecagonal number ; Condition to check if the number is a Centered nonadecagonal number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isCenterednonadecagonal ( int N ) { float n = ( float ) ( ( 19 + Math . Sqrt ( 152 * N + 209 ) ) / 38 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( ) { int n = 20 ; if ( isCenterednonadecagonal ( n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Chiliagon Number | C # program for the above approach ; Function to check that if N is Chiliagon Number or not ; Condition to check if N is a Chiliagon Number ; Driver Code ; Given Number ; Function call"
Solution in C#:

using System ; class GFG { static bool is_Chiliagon ( int N ) { float n = ( float ) ( 996 + Math . Sqrt ( 7984 * N + 992016 ) ) / 1996 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( ) { int N = 1000 ; if ( is_Chiliagon ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Concentric Hexagonal Number | C # program to check if N is a concentric hexagonal number ; Function to check if the number is a concentric hexagonal number ; Condition to check if the number is a concentric hexagonal number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isConcentrichexagonal ( int N ) { float n = ( float ) Math . Sqrt ( ( 2 * N ) / 3 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( ) { int N = 6 ; if ( isConcentrichexagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Decagonal Number | C # program for the above approach ; Function to check if N is a decagonal Number ; Condition to check if the number is a decagonal number ; Driver Code ; Given Number ; Function call"
Solution in C#:

using System ; class GFG { static bool isdecagonal ( int N ) { double n = ( 3 + Math . Sqrt ( 16 * N + 9 ) ) / 8 ; return ( n - ( int ) n ) == 0 ; } static public void Main ( ) { int N = 10 ; if ( isdecagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Dodecagonal Number | C # program for the above approach ; Function to check if number N is a dodecagonal number or not ; Condition to check if the N is a dodecagonal number ; Driver Code ; Given number ; Function call"
Solution in C#:

using System ; class GFG { static bool isdodecagonal ( int N ) { float n = ( float ) ( ( 4 + Math . Sqrt ( 20 * N + 16 ) ) / 10 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( string [ ] args ) { int N = 12 ; if ( isdodecagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Enneadecagonal Number | C # program for the above approach ; Function to check if number N is a enneadecagonal number ; Condition to check if N is a enneadecagonal number ; Driver Code ; Given number ; Function call"
Solution in C#:

using System ; class GFG { static bool isenneadecagonal ( int N ) { float n = ( float ) ( 15 + Math . Sqrt ( 136 * N + 225 ) ) / 34 ; return ( n - ( int ) n ) == 0 ; } static public void Main ( ) { int N = 19 ; if ( isenneadecagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Hendecagonal Number | C # program for the above approach ; Function to check if N is a hendecagonal number ; Condition to check if the number is a hendecagonal number ; Driver code ; Given number ; Function call"
Solution in C#:

 using System ; class GFG { public static bool ishendecagonal ( int N ) { double n = ( 7 + Math . Sqrt ( 72 * N + 49 ) ) / 18 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( string [ ] args ) { int N = 11 ; if ( ishendecagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No
 " ) ; } } }


"Program to check if N is a Heptagonal Number | C # program for the above approach ; Function to check if N is a heptagonal number ; Condition to check if the number is a heptagonal number ; Driver code ; Given Number ; Function call"
Solution in C#:

using System ; class GFG { public static bool isheptagonal ( int N ) { double n = ( 3 + Math . Sqrt ( 40 * N + 9 ) ) / 10 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( String [ ] args ) { int N = 7 ; if ( isheptagonal ( N ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }


"Program to check if N is a Hexadecagonal Number | C # program for the above approach ; Function to check if N is a hexadecagonal number ; Condition to check if the number is a hexadecagonal number ; Driver code ; Given number ; Function call"
Solution in C#:

using System ; class GFG { public static bool ishexadecagonal ( int N ) { double n = ( 12 + Math . Sqrt ( 112 * N + 144 ) ) / 28 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( string [ ] args ) { int N = 16 ; if ( ishexadecagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Hexagonal Number or not | C # program to check if N is a hexagonal number ; Function to check if number is hexagonal ; Calculate the value for n ; Check if n - floor ( n ) is equal to 0 ; Driver code"
Solution in C#:

using System ; class GFG { static bool isHexagonal ( int N ) { float val = 8 * N + 1 ; float x = 1 + ( float ) Math . Sqrt ( val ) ; float n = ( x ) / 4 ; if ( ( n - ( int ) n ) == 0 ) { return true ; } else { return false ; } } public static void Main ( string [ ] args ) { int N = 14 ; if ( isHexagonal ( N ) == true ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }


"Program to check if N is a Icosihenagonal number | C # implementation to check that a number is icosihenagonal number or not ; Function to check that the number is a icosihenagonal number ; Condition to check if the number is a icosihenagonal number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isicosihenagonal ( int N ) { float n = ( float ) ( ( 17 + Math . Sqrt ( 152 * N + 289 ) ) / 38 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( ) { int i = 21 ; if ( isicosihenagonal ( i ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Icositetragonal number | C # implementation to check that a number is icositetragonal number or not ; Function to check that the number is a icositetragonal number ; Condition to check if the number is a icositetragonal number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isicositetragonal ( int N ) { float n = ( float ) ( ( 10 + Math . Sqrt ( 44 * N + 100 ) ) / 22 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( ) { int i = 24 ; if ( isicositetragonal ( i ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Icositrigonal number | C # implementation to check that a number is a icositrigonal number or not ; Function to check that the number is a icositrigonal number ; Condition to check if the number is a icositrigonal number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isicositrigonal ( int N ) { float n = ( float ) ( 19 + Math . Sqrt ( 168 * N + 361 ) ) / 42 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( ) { int i = 23 ; if ( isicositrigonal ( i ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Myriagon Number | C # program for the above approach ; Function to check if N is a myriagon number ; Condition to check if the number is a myriagon number ; Driver Code ; Given Number ; Function call"
Solution in C#:

using System ; class GFG { static bool isMyriagon ( int N ) { double n = ( 9996 + Math . Sqrt ( 79984 * N + 99920016 ) ) / 19996 ; return ( n - ( int ) n ) == 0 ; } static public void Main ( ) { int N = 10000 ; if ( isMyriagon ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Nonagonal Number | C # program for the above approach ; Function to check if N is a nonagonal number ; Condition to check if the number is a nonagonal number ; Driver code ; Given number ; Function call"
Solution in C#:

using System ; class GFG { public static bool isnonagonal ( int N ) { double n = ( 5 + Math . Sqrt ( 56 * N + 25 ) ) / 14 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( string [ ] args ) { int N = 9 ; if ( isnonagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Octadecagon number | C # program for the above approach ; Function to check if N is a octadecagon Number ; Condition to check if the number is a octadecagon number ; Driver Code ; Given Number ; Function call"
Solution in C#:

using System ; class GFG { public static bool isOctadecagon ( int N ) { double n = ( 14 + Math . Sqrt ( 128 * N + 196 ) ) / 32 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( String [ ] args ) { int N = 18 ; if ( isOctadecagon ( N ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }


"Program to check if N is a Octagonal Number | C # program for the above approach ; Function to check if N is a octagonal number ; Condition to check if the number is a octagonal number ; Driver code ; Given number ; Function call"
Solution in C#:

using System ; class GFG { public static bool isoctagonal ( int N ) { double n = ( 2 + Math . Sqrt ( 12 * N + 4 ) ) / 6 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( String [ ] args ) { int N = 8 ; if ( isoctagonal ( N ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }


"Program to check if N is a Pentadecagonal Number | C # program for the above approach ; Function to check if N is a pentadecagon number ; Condition to check if the number is a pentadecagon number ; Driver code ; Given Number ; Function call"
Solution in C#:

using System ; class GFG { public static bool isPentadecagon ( int N ) { double n = ( 11 + Math . Sqrt ( 104 * N + 121 ) ) / 26 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( String [ ] args ) { int N = 15 ; if ( isPentadecagon ( N ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }


"Program to check if N is a Pentagonal Number | C # program to check pentagonal numbers . ; Function to determine if N is pentagonal or not . ; Substitute values of i in the formula . ; Driver Code"
Solution in C#:

using System ; class GFG { static bool isPentagonal ( int N ) { int i = 1 , M ; do { M = ( 3 * i * i - i ) / 2 ; i += 1 ; } while ( M < N ) ; return ( M == N ) ; } public static void Main ( ) { int N = 12 ; if ( isPentagonal ( N ) ) Console . Write ( N + " ▁ is ▁ pentagonal ▁ " ) ; else Console . Write ( N + " ▁ is ▁ not ▁ pentagonal " ) ; } }


"Program to check if N is a Star Number | C # implementation to check that a number is a star number or not ; Function to check that the number is a star number ; Condition to check if the number is a star number ; Driver code ; Function call"
Solution in C#:

using System ; class GFG { static bool isStar ( int N ) { double n = ( 6 + Math . Sqrt ( 24 * N + 12 ) ) / 6 ; return ( n - ( int ) n ) == 0 ; } public static void Main ( ) { int i = 13 ; if ( isStar ( i ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }


"Program to check if N is a Tetradecagonal Number | C # program for the above approach ; Function to check if N is a tetradecagonal number ; Condition to check if the number is a tetradecagonal number ; Driver Code ; Given number ; Function call"
Solution in C#:

using System ; class GFG { public static bool istetradecagonal ( int N ) { double n = ( 10 + Math . Sqrt ( 96 * N + 100 ) ) / 24 ; return ( n - ( int ) n ) == 0 ; } static public void Main ( ) { int N = 11 ; if ( istetradecagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a Tridecagonal Number or not | C # implementation to check that a number is a tridecagon number or not ; Function to check that the number is a tridecagon number ; Condition to check if the number is a tridecagon number ; Driver Code ; Function call"
Solution in C#:

using System ; class GFG { static bool isTridecagon ( int N ) { float n = ( float ) ( ( 9 + Math . Sqrt ( 88 * N + 81 ) ) / 22 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( ) { int i = 13 ; if ( isTridecagon ( i ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if N is a triacontagonal number | C # program to check whether a number is an triacontagonal number or not ; Function to check whether a number is an triacontagonal number or not ; Condition to check whether a number is an triacontagonal number or not ; Driver code ; Given number ; Function call"
Solution in C#:

using System ; class GFG { static bool istriacontagonal ( int N ) { float n = ( float ) ( ( 26 + Math . Sqrt ( 224 * N + 676 ) ) / 56 ) ; return ( n - ( int ) n ) == 0 ; } public static void Main ( String [ ] args ) { int N = 30 ; if ( istriacontagonal ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }


"Program to check if a number can be expressed as an even power of 2 or not | C # program for the above approach ; Function to check if N can be expressed as an even power of 2 ; Iterate till x is N ; if x is even then return true ; Increment x ; If N is not a power of 2 ; Driver Code"
Solution in C#:

using System ; using System . Collections . Generic ; class GFG { static bool checkEvenPower ( int n ) { int x = 0 ; while ( x < n ) { int value = ( int ) Math . Pow ( 2 , x ) ; if ( value == n ) { if ( x % 2 == 0 ) return true ; else return false ; } x ++ ; } return false ; } static public void Main ( ) { int N = 4 ; Console . Write ( ( checkEvenPower ( N ) ? " Yes " : " No " ) ) ; } }


"Program to check if a number can be expressed as an even power of 2 or not | C # program for the above approach ; Function to check if N can be expressed as an even power of 2 or not ; If N is not a power of 2 ; Bitwise AND operation ; Driver Code"
Solution in C#:

using System ; public class GFG { static bool checkEvenPower ( long N ) { if ( ( N & ( N - 1 ) ) != 0 ) return false ; N = N & 0x55555555 ; return ( N > 0 ) ; } public static void Main ( String [ ] args ) { long N = 4 ; Console . WriteLine ( checkEvenPower ( N ) ? 1 : 0 ) ; } }


"Program to check if a number can be expressed as an even power of 2 or not | C # program for the above approach ; Function to check if N can be expressed as an even power of 2 or not ; Iterate until low > high ; Calculate mid ; If 2 ^ mid is equal to n ; If mid is odd ; Update the value of low ; Update the value of high ; Otherwise ; Driver code"
Solution in C#:

using System ; public class GFG { static String checkEvenPower ( int n ) { int low = 0 , high = n ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; int value = ( int ) Math . Pow ( 2 , mid ) ; if ( value == n ) { if ( mid % 2 == 1 ) return " No " ; else return " Yes " ; } else if ( value < n ) low = mid + 1 ; else high = mid - 1 ; } return " No " ; } public static void Main ( String [ ] args ) { int N = 4 ; Console . WriteLine ( checkEvenPower ( N ) ) ; } }


"Program to check if a number is divisible by any of its digits | C # implementation of above approach ; Converting integer to string ; Traversing the string ; find the actual digit ; If the number is divisible by digits then return yes ; If no digits are dividing the number then return no ; Driver Code ; passing this number to get result function"
Solution in C#:

using System ; public class GFG { static String getResult ( int n ) { string st = n . ToString ( ) ; for ( int i = 0 ; i < st . Length ; i ++ ) { int d = st [ i ] - 48 ; if ( n % d == 0 ) { return " Yes " ; } } return " No " ; } public static void Main ( String [ ] args ) { int n = 9876543 ; Console . Write ( getResult ( n ) ) ; } }


"Program to check if a number is divisible by any of its digits | C # implementation of above approach ; Function to check if given number is divisible by any of its digits ; check if any of digit divides n ; check if K divides N ; Driver Code"
Solution in C#:

using System ; class GFG { static String isDivisible ( int n ) { int temp = n ; while ( n > 0 ) { int k = n % 10 ; if ( temp % k == 0 ) { return " YES " ; } n /= 10 ; } return " NO " ; } public static void Main ( String [ ] args ) { int n = 9876543 ; Console . WriteLine ( isDivisible ( n ) ) ; } }


"Program to check if a number is divisible by sum of its digits | C # implementation of above approach ; Converting integer to String ; Initialising sum to 0 ; Traversing through the String ; Converting character to int ; Comparing number and sum ; Driver Code ; Passing this number to get result function"
Solution in C#:

using System ; public class GFG { static String getResult ( int n ) { String st = String . Join ( " " , n ) ; int sum = 0 ; foreach ( char i in st . ToCharArray ( ) ) { sum = sum + ( int ) i ; } if ( n % sum == 0 ) return " Yes " ; else return " No " ; } public static void Main ( String [ ] args ) { int n = 123 ; Console . WriteLine ( getResult ( n ) ) ; } }


"Program to check if a number is divisible by sum of its digits | C # implementation of above approach ; Function to check if the given number is divisible by sum of its digits ; Find sum of digits ; check if sum of digits divides n ; Driver Code"
Solution in C#:

using System ; class GFG { static String isDivisible ( long n ) { long temp = n ; int sum = 0 ; while ( n != 0 ) { int k = ( int ) n % 10 ; sum += k ; n /= 10 ; } if ( temp % sum == 0 ) return " YES " ; return " NO " ; } public static void Main ( ) { long n = 123 ; Console . WriteLine ( isDivisible ( n ) ) ; } }


"Program to check if all characters have even frequency | C # implementation of the approach ; creating a frequency array ; Finding length of s ; counting frequency of all characters ; checking if any odd frequency is there or not ; Driver Code"
Solution in C#:

using System ; class GFG { static Boolean check ( String s ) { int [ ] freq = new int [ 26 ] ; int n = s . Length ; for ( int i = 0 ; i < s . Length ; i ++ ) { freq [ ( s [ i ] ) - 97 ] += 1 ; } for ( int i = 0 ; i < freq . Length ; i ++ ) { if ( freq [ i ] % 2 == 1 ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String s = " abaccaba " ; if ( check ( s ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }


"Program to check if tank will overflow , underflow or filled in given time | C # program to check if Tank will overflow or not in given time ; function to calculate the volume of tank ; function to print overflow / filled / underflow accordingly ; driver code ; radius of the tank ; height of the tank ; rate of flow of water ; time given ; calculate the required time ; printing the result"
Solution in C#:

using System ; class Number { public static float volume ( int radius , int height ) { return ( ( 22 / 7 ) * radius * radius * height ) ; } public static void check_and_print ( double required_time , double given_time ) { if ( required_time < given_time ) Console . WriteLine ( " Overflow " ) ; else if ( required_time > given_time ) Console . WriteLine ( " Underflow " ) ; else Console . WriteLine ( " Filled " ) ; } public static void Main ( ) { int radius = 5 , height = 10 , rate_of_flow = 10 ; double given_time = 70.0 ; double required_time = volume ( radius , height ) / rate_of_flow ; check_and_print ( required_time , given_time ) ; } }


"Program to check if the points are parallel to X axis or Y axis | C # program to illustrate . . To check for parallel To X and Y Axis ; To check for parallel line ; checking for parallel to X and Y axis condition ; To display the output ; Driver code"
Solution in C#:

class GFG { static void parallel ( int [ , ] a ) { bool x = true , y = true ; for ( int i = 0 ; i < a . Rank - 1 ; i ++ ) { if ( a [ i , 0 ] != a [ i + 1 , 0 ] ) x = false ; if ( a [ i , 1 ] != a [ i + 1 , 1 ] ) y = false ; } if ( x ) System . Console . WriteLine ( " Parallel ▁ to ▁ Y ▁ Axis " ) ; else if ( y ) System . Console . WriteLine ( " Parallel ▁ to ▁ X ▁ Axis " ) ; else System . Console . WriteLine ( " Not ▁ parallel ▁ to ▁ X " + " ▁ and ▁ Y ▁ axis " ) ; } public static void Main ( ) { int [ , ] a = { { 1 , 2 } , { 1 , 4 } , { 1 , 6 } , { 1 , 0 } } ; parallel ( a ) ; } }


"Program to check if three points are collinear | Slope based solution to check if three points are collinear . ; function to check if point collinear or not ; Driver Code"
Solution in C#:

using System ; class GFG { static void cool_line ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { if ( ( y3 - y2 ) * ( x2 - x1 ) == ( y2 - y1 ) * ( x3 - x2 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static public void Main ( ) { int a1 = 1 , a2 = 1 , a3 = 0 , b1 = 1 , b2 = 6 , b3 = 9 ; cool_line ( a1 , b1 , a2 , b2 , a3 , b3 ) ; } }


"Program to check if water tank overflows when n solid balls are dipped in the water tank | C # Code for Program to check if water tank overflows ; function to find if tak will overflow or not ; cylinder capacity ; volume of water in tank ; volume of n balls ; total volume of water and n dipped balls ; condition to check if tank is in overflow state or not ; Driver program to test above function ; giving dimensions ; calling function"
Solution in C#:

using System ; class GFG { static void overflow ( int H , int r , int h , int N , int R ) { double tank_cap = 3.14 * r * r * H ; double water_vol = 3.14 * r * r * h ; double balls_vol = N * ( 4 / 3 ) * 3.14 * R * R * R ; double vol = water_vol + balls_vol ; if ( vol > tank_cap ) { Console . WriteLine ( " Overflow " ) ; } else { Console . WriteLine ( " Not ▁ in ▁ overflow ▁ state " ) ; } } public static void Main ( ) { int H = 10 , r = 5 , h = 5 , N = 2 , R = 2 ; overflow ( H , r , h , N , R ) ; } }


"Program to check similarity of given two triangles | C # program to check similarity between two triangles . ; Function for AAA similarity ; Check for AAA ; Function for SAS similarity ; angle b / w two smallest sides is largest . ; since we take angle b / w the sides . ; Function for SSS similarity ; Check for SSS ; Driver Code ; function call for AAA similarity ; function call for SSS similarity ; function call for SAS similarity ; Check if triangles are similar or not"
Solution in C#:

using System ; class GFG1 { static int simi_aaa ( int [ ] a1 , int [ ] a2 ) { Array . Sort ( a1 ) ; Array . Sort ( a2 ) ; if ( a1 [ 0 ] == a2 [ 0 ] && a1 [ 1 ] == a2 [ 1 ] && a1 [ 2 ] == a2 [ 2 ] ) return 1 ; else return 0 ; } static int simi_sas ( int [ ] s1 , int [ ] s2 , int [ ] a1 , int [ ] a2 ) { Array . Sort ( a1 ) ; Array . Sort ( a2 ) ; Array . Sort ( s1 ) ; Array . Sort ( s2 ) ; if ( s1 [ 0 ] / s2 [ 0 ] == s1 [ 1 ] / s2 [ 1 ] ) { if ( a1 [ 2 ] == a2 [ 2 ] ) return 1 ; } if ( s1 [ 1 ] / s2 [ 1 ] == s1 [ 2 ] / s2 [ 2 ] ) { if ( a1 [ 0 ] == a2 [ 0 ] ) return 1 ; } if ( s1 [ 2 ] / s2 [ 2 ] == s1 [ 0 ] / s2 [ 0 ] ) { if ( a1 [ 1 ] == a2 [ 1 ] ) return 1 ; } return 0 ; } static int simi_sss ( int [ ] s1 , int [ ] s2 ) { Array . Sort ( s1 ) ; Array . Sort ( s2 ) ; if ( s1 [ 0 ] / s2 [ 0 ] == s1 [ 1 ] / s2 [ 1 ] && s1 [ 1 ] / s2 [ 1 ] == s1 [ 2 ] / s2 [ 2 ] && s1 [ 2 ] / s2 [ 2 ] == s1 [ 0 ] / s2 [ 0 ] ) return 1 ; return 0 ; } public static void Main ( ) { int [ ] s1 = { 2 , 3 , 3 } ; int [ ] s2 = { 4 , 6 , 6 } ; int [ ] a1 = { 80 , 60 , 40 } ; int [ ] a2 = { 40 , 60 , 80 } ; int aaa = simi_aaa ( a1 , a2 ) ; int sss = simi_sss ( s1 , s2 ) ; int sas = simi_sas ( s1 , s2 , a1 , a2 ) ; if ( aaa == 1 sss == 1 sas == 1 ) { Console . Write ( " Triangles ▁ are ▁ " + " similar ▁ by ▁ " ) ; if ( aaa == 1 ) Console . Write ( " AAA ▁ " ) ; if ( sss == 1 ) Console . Write ( " SSS ▁ " ) ; if ( sas == 1 ) Console . Write ( " SAS . " ) ; } else Console . WriteLine ( " Triangles ▁ are ▁ " + " not ▁ similar " ) ; } }


"Program to check whether 4 points in a 3 | C # program to check if 4 points in a 3 - D plane are Coplanar ; Function to find equation of plane . ; checking if the 4 th point satisfies the above equation ; Driver Code ; function calling"
Solution in C#:

using System ; class GFG { static void equation_plane ( int x1 , int y1 , int z1 , int x2 , int y2 , int z2 , int x3 , int y3 , int z3 , int x , int y , int z ) { int a1 = x2 - x1 ; int b1 = y2 - y1 ; int c1 = z2 - z1 ; int a2 = x3 - x1 ; int b2 = y3 - y1 ; int c2 = z3 - z1 ; int a = b1 * c2 - b2 * c1 ; int b = a2 * c1 - a1 * c2 ; int c = a1 * b2 - b1 * a2 ; int d = ( - a * x1 - b * y1 - c * z1 ) ; if ( a * x + b * y + c * z + d == 0 ) Console . WriteLine ( " Coplanar " ) ; else Console . WriteLine ( " Not ▁ Coplanar " ) ; } static public void Main ( ) { int x1 = 3 ; int y1 = 2 ; int z1 = - 5 ; int x2 = - 1 ; int y2 = 4 ; int z2 = - 3 ; int x3 = - 3 ; int y3 = 8 ; int z3 = - 5 ; int x4 = - 3 ; int y4 = 2 ; int z4 = 1 ; equation_plane ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 , x4 , y4 , z4 ) ; } }


"Program to check whether a number is Proth number or not | C # program to check Proth number ; Utility function to check power of two ; Function to check if the Given number is Proth number or not ; check if k divides n or not ; Check if n / k is power of 2 or not ; update k to next odd number ; If we reach here means there exists no value of K Such that k is odd number and n / k is a power of 2 greater than k ; Driver code ; Get n ; Check n for Proth Number"
Solution in C#:

using System ; class GFG { static bool isPowerOfTwo ( int n ) { return n != 0 && ( ( n & ( n - 1 ) ) == 0 ) ; } static bool isProthNumber ( int n ) { int k = 1 ; while ( k < ( n / k ) ) { if ( n % k == 0 ) { if ( isPowerOfTwo ( n / k ) ) return true ; } k = k + 2 ; } return false ; } public static void Main ( ) { int n = 25 ; if ( isProthNumber ( n - 1 ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }


"Program to clear K | C # program to clear K - th bit of a number N ; Function to clear the kth bit of n ; Driver code"
Solution in C#:

using System ; class GFG { static int clearBit ( int n , int k ) { return ( n & ( ~ ( 1 << ( k - 1 ) ) ) ) ; } public static void Main ( String [ ] args ) { int n = 5 , k = 1 ; Console . WriteLine ( clearBit ( n , k ) ) ; } }


"Program to compare m ^ n and n ^ m | C # program to compare which is greater m ^ n or n ^ m ; function to compare m ^ n and n ^ m ; m ^ n ; n ^ m ; Driver Code ; function call to compare m ^ n and n ^ m"
Solution in C#:

using System ; class GFG { static void check ( ulong m , ulong n ) { double RHS = m * ( double ) Math . Log ( n ) ; double LHS = n * ( double ) Math . Log ( m ) ; if ( LHS > RHS ) Console . Write ( " m ^ n ▁ > ▁ n ^ m " ) ; else if ( LHS < RHS ) Console . Write ( " m ^ n ▁ < ▁ n ^ m " ) ; else Console . Write ( " m ^ n ▁ = ▁ n ^ m " ) ; } static public void Main ( ) { ulong m = 987654321 , n = 123456987 ; check ( m , n ) ; } }


"Program to compare two fractions | C # program to find max between two Rational numbers ; Constructor ; Get max of the two fractions ; Declare nume1 and nume2 for get the value of first numerator and second numerator ; Compute ad - bc ; Driver function"
Solution in C#:

using System ; class Fraction { int num , den ; Fraction ( int n , int d ) { num = n ; den = d ; } static Fraction maxFraction ( Fraction first , Fraction sec ) { int a = first . num ; int b = first . den ; int c = sec . num ; int d = sec . den ; int Y = a * d - b * c ; return ( Y > 0 ) ? first : sec ; } public static void Main ( ) { Fraction first = new Fraction ( 3 , 2 ) ; Fraction sec = new Fraction ( 3 , 4 ) ; Fraction res = maxFraction ( first , sec ) ; Console . WriteLine ( res . num + " / " + res . den ) ; } }


"Program to compute division upto n decimal places | C # program to compute division upto n decimal places . ; Base cases ; Since n <= 0 , don 't compute after  the decimal ; Handling negative numbers ; Integral division ; Now one by print digits after dot using school division method . ; Driver code"
Solution in C#:

using System ; class Eulerian { public static void precisionCompute ( int x , int y , int n ) { if ( y == 0 ) { Console . WriteLine ( " Infinite " ) ; return ; } if ( x == 0 ) { Console . WriteLine ( "0" ) ; return ; } if ( n <= 0 ) { Console . WriteLine ( x / y ) ; return ; } if ( ( ( x > 0 ) && ( y < 0 ) ) || ( ( x < 0 ) && ( y > 0 ) ) ) { Console . WriteLine ( " - " ) ; x = x > 0 ? x : - x ; y = y > 0 ? y : - y ; } int d = x / y ; for ( int i = 0 ; i <= n ; i ++ ) { Console . Write ( d ) ; x = x - ( y * d ) ; if ( x == 0 ) break ; x = x * 10 ; d = x / y ; if ( i == 0 ) Console . Write ( " . " ) ; } } public static void Main ( ) { int x = 22 , y = 7 , n = 15 ; precisionCompute ( x , y , n ) ; } }


"Program to compute log a to any base b ( logb a ) | C # program to find log ( a ) on any base b ; Driver code"
Solution in C#:

using System ; public class GFG { static int log_a_to_base_b ( int a , int b ) { return ( int ) ( Math . Log ( a ) / Math . Log ( b ) ) ; } public static void Main ( ) { int a = 3 ; int b = 2 ; Console . WriteLine ( log_a_to_base_b ( a , b ) ) ; a = 256 ; b = 4 ; Console . WriteLine ( log_a_to_base_b ( a , b ) ) ; } }


"Program to compute log a to any base b ( logb a ) | C # program to find log ( a ) on any base b using Recursion ; Recursive function to compute log a to the base b ; Driver code"
Solution in C#:

using System ; class GFG { static int log_a_to_base_b ( int a , int b ) { int rslt = ( a > b - 1 ) ? 1 + log_a_to_base_b ( a / b , b ) : 0 ; return rslt ; } public static void Main ( ) { int a = 3 ; int b = 2 ; Console . WriteLine ( log_a_to_base_b ( a , b ) ) ; a = 256 ; b = 4 ; Console . WriteLine ( log_a_to_base_b ( a , b ) ) ; } }


"Program to construct DFA accepting odd number of 0 s and odd number of 1 s | C # program for the above approach ; Function to check whether the given string is accepted by DFA or not ; Stores final state of DFA ; Stores previous state of DFA ; Iterate through the string ; Checking for all combinations ; Update the previous_state ; If final state is reached ; Otherwise ; Driver Code ; Given string ; Function Call"
Solution in C#:

using System ; class GFG { static void checkValidDFA ( string s ) { int final_state = 0 ; int previous_state = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( ( s [ i ] == '0' && previous_state == 0 ) || ( s [ i ] == '1' && previous_state == 3 ) ) { final_state = 1 ; } else if ( ( s [ i ] == '0' && previous_state == 3 ) || ( s [ i ] == '1' && previous_state == 0 ) ) { final_state = 2 ; } else if ( ( s [ i ] == '0' && previous_state == 1 ) || ( s [ i ] == '1' && previous_state == 2 ) ) { final_state = 0 ; } else if ( ( s [ i ] == '0' && previous_state == 2 ) || ( s [ i ] == '1' && previous_state == 1 ) ) { final_state = 3 ; } previous_state = final_state ; } if ( final_state == 3 ) { Console . WriteLine ( " Accepted " ) ; } else { Console . WriteLine ( " Not ▁ Accepted " ) ; } } public static void Main ( ) { string s = "010011" ; checkValidDFA ( s ) ; } }


"Program to construct a DFA to check if a given integer is unsigned or not | C # program for the above approach ; Function to construct DFA as per the given conditions ; If at state 0 and a digit has occurred then set it to state 1 ; Similarly for all other states ; Function to build and connect the DFA states ; Connect all the states to the dead state ; Function call to make DFA as per the given conditions ; Function call to check whether an integer in the form of string is unsigned integer or not ; Build the DFA ; Stores the current state ; Traverse the string ; If at a certain state a digit occurs then change the current state according to the DFA ; Or + / - sign ; Or decimal occurred ; Or any other character ; Or e / E or exponent sign ; State 1 , 4 , 8 will give the final answer ; Driver Code"
Solution in C#:

using System ; class GFG { static string digits = "0123456789" , sign = " + - " ; static string dot = " . " , ex = " eE " ; static int [ , ] dfa = new int [ 11 , 5 ] ; static void makeDFA ( ) { dfa [ 0 , 0 ] = 1 ; dfa [ 1 , 0 ] = 1 ; dfa [ 1 , 2 ] = 3 ; dfa [ 1 , 3 ] = 2 ; dfa [ 1 , 4 ] = 6 ; dfa [ 3 , 0 ] = 4 ; dfa [ 4 , 0 ] = 4 ; dfa [ 4 , 3 ] = 5 ; dfa [ 4 , 4 ] = 6 ; dfa [ 6 , 0 ] = 8 ; dfa [ 6 , 1 ] = 7 ; dfa [ 7 , 0 ] = 8 ; dfa [ 8 , 0 ] = 8 ; dfa [ 8 , 3 ] = 9 ; } static void buildDFA ( ) { for ( int i = 0 ; i < 11 ; i ++ ) for ( int j = 0 ; j < 5 ; j ++ ) dfa [ i , j ] = 10 ; makeDFA ( ) ; } static void checkDFA ( string s ) { buildDFA ( ) ; int currentstate = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( digits . IndexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate , 0 ] ; else if ( sign . IndexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate , 1 ] ; else if ( dot . IndexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate , 2 ] ; else if ( ex . IndexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate , 4 ] ; else currentstate = dfa [ currentstate , 3 ] ; } if ( currentstate == 1 currentstate == 4 currentstate == 8 ) { Console . WriteLine ( " Unsigned ▁ integer " ) ; } else { Console . WriteLine ( " Not ▁ an ▁ unsigned ▁ integer " ) ; } } public static void Main ( string [ ] args ) { string S = "1729" ; checkDFA ( S ) ; } }


"Program to construct a DFA which accepts the language L = { aN | N â ‰¥ 1 } | C # program for the above approach ; Function to check whether the String S satisfy the given DFA or not ; Stores the count of characters ; Iterate over the range [ 0 , N ] ; Count and check every element for ' a ' ; If String matches with DFA ; If not matches ; Driver Code ; Function Call"
Solution in C#:

using System ; class GFG { static void isAcceptedDFA ( String s , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == ' a ' ) count ++ ; } if ( count == N && count != 0 ) { Console . Write ( " Accepted " ) ; } else { Console . Write ( " Not ▁ Accepted " ) ; } } public static void Main ( String [ ] args ) { String S = " aaaaa " ; isAcceptedDFA ( S , S . Length ) ; } }


"Program to convert Degree to Radian | C # program to convert degree to radian ; Function for conversion ; Driver code"
Solution in C#:

using System ; class GFG { static double Convert ( double degree ) { double pi = 3.14159265359 ; return ( degree * ( pi / 180 ) ) ; } public static void Main ( ) { double degree = 30 ; double radian = Convert ( degree ) ; Console . Write ( " { 0 : F6 } " , radian ) ; } }


"Program to convert Hexa | C # implementation to convert the given HexaDecimal number to its equivalent BCD . ; Function to convert HexaDecimal to its BCD ; Iterating through the digits ; check whether s [ i ] is a character or a integer between 0 to 9 and compute its equivalent BCD ; Driver Code ; Function Call"
Solution in C#:

using System ; class GFG { static void HexaDecimaltoBCD ( string s ) { int len = s . Length ; for ( int i = 0 ; i <= len - 1 ; i ++ ) { if ( s [ i ] >= 47 && s [ i ] <= 52 ) { string result = Convert . ToString ( ( int ) s [ i ] , 2 ) ; Console . Write ( result . Substring ( result . Length - 4 ) + " ▁ " ) ; } else { string result = Convert . ToString ( ( int ) s [ i ] - 55 , 2 ) ; Console . Write ( result . Substring ( result . Length - 4 ) + " ▁ " ) ; } } } static void Main ( ) { string s = "11F " ; HexaDecimaltoBCD ( s ) ; } }


"Program to convert KiloBytes to Bytes and Bits | C # implementation of above program ; Function to calculates the bits ; calculates Bits 1 kilobytes ( s ) = 8192 bits ; Function to calculates the bytes ; calculates Bytes 1 KB = 1024 bytes ; Driver code"
Solution in C#:

using System ; class GFG { static long Bits ( int kilobytes ) { long Bits = 0 ; Bits = kilobytes * 8192 ; return Bits ; } static long Bytes ( int kilobytes ) { long Bytes = 0 ; Bytes = kilobytes * 1024 ; return Bytes ; } static public void Main ( ) { int kilobytes = 1 ; Console . WriteLine ( kilobytes + " ▁ Kilobytes ▁ = ▁ " + Bytes ( kilobytes ) + " ▁ Bytes ▁ and ▁ " + Bits ( kilobytes ) + " ▁ Bits . " ) ; } }


"Program to convert Number in characters | C # program to convert number in characters ; To calculate the reverse of the number ; The remainder will give the last digit of the number ; Extract the first digit of the reversed number ; Match it with switch case ; Divide the number by 10 to get the next number ; Driver code"
Solution in C#:

using System ; class GFG { static void NumbertoCharacter ( int n ) { int rev = 0 , r = 0 ; while ( n > 0 ) { r = n % 10 ; rev = rev * 10 + r ; n = n / 10 ; } while ( rev > 0 ) { r = rev % 10 ; switch ( r ) { 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 ; case 0 : Console . Write ( " zero ▁ " ) ; break ; default : Console . Write ( " UnValid ▁ " ) ; break ; } rev = rev / 10 ; } } public static void Main ( String [ ] args ) { int n = 12345 ; NumbertoCharacter ( n ) ; } }


"Program to convert a Binary Number to Hexa | C # code to convert BCD to its HexaDecimal number ( base 16 ) . Including Header Files ; Function to convert BCD to HexaDecimal ; Iterating through the bits backwards ; Computing the HexaDecimal Number formed so far and storing it in a vector . ; Reinitializing all variables for next group . ; Printing the Hexadecimal number formed so far . ; Driver Code ; Function Call"
Solution in C#:

using System ; using System . Collections . Generic ; class GFG { static void bcdToHexaDecimal ( char [ ] s ) { int len = s . Length , check = 0 ; int num = 0 , sum = 0 , mul = 1 ; List < char > ans = new List < char > ( ) ; for ( int i = len - 1 ; i >= 0 ; i -- ) { sum += ( s [ i ] - '0' ) * mul ; mul *= 2 ; check ++ ; if ( check == 4 i == 0 ) { if ( sum <= 9 ) ans . Add ( ( char ) ( sum + '0' ) ) ; else ans . Add ( ( char ) ( sum + 55 ) ) ; check = 0 ; sum = 0 ; mul = 1 ; } } len = ans . Count ; for ( int i = len - 1 ; i >= 0 ; i -- ) Console . Write ( ans [ i ] ) ; } public static void Main ( String [ ] args ) { String s = "100000101111" ; bcdToHexaDecimal ( s . ToCharArray ( ) ) ; } }


"Program to convert a given number to words | C # program to print a given number in words . The program handles numbers from 0 to 9999 ; A function that prints given number in words ; Get number of digits in given number ; Base cases ; The first string is not used , it is to make array indexing simple ; The first string is not used , it is to make array indexing simple ; The first two string are not used , they are to make array indexing simple ; Used for debugging purpose only ; For single digit number ; Iterate while num is not ' \0' ; Code path for first 2 digits ; here len can be 3 or 4 ; Code path for last 2 digits ; Need to explicitly handle 10 - 19. Sum of the two digits is used as index of " two _ digits " array of strings ; Need to explicitely handle 20 ; Rest of the two digit numbers i . e . , 21 to 99 ; Driver Code"
Solution in C#:

using System ; class GFG { static void convert_to_words ( char [ ] num ) { int len = num . Length ; if ( len == 0 ) { Console . WriteLine ( " empty ▁ string " ) ; return ; } if ( len > 4 ) { Console . WriteLine ( " Length ▁ more ▁ than ▁ " + "4 ▁ is ▁ not ▁ supported " ) ; return ; } string [ ] single_digits = new string [ ] { " zero " , " one " , " two " , " three " , " four " , " five " , " six " , " seven " , " eight " , " nine " } ; string [ ] two_digits = new string [ ] { " " , " ten " , " eleven " , " twelve " , " thirteen " , " fourteen " , " fifteen " , " sixteen " , " seventeen " , " eighteen " , " nineteen " } ; string [ ] tens_multiple = new string [ ] { " " , " " , " twenty " , " thirty " , " forty " , " fifty " , " sixty " , " seventy " , " eighty " , " ninety " } ; string [ ] tens_power = new string [ ] { " hundred " , " thousand " } ; Console . Write ( ( new string ( num ) ) + " : ▁ " ) ; if ( len == 1 ) { Console . WriteLine ( single_digits [ num [ 0 ] - '0' ] ) ; return ; } int x = 0 ; while ( x < num . Length ) { if ( len >= 3 ) { if ( num [ x ] - '0' != 0 ) { Console . Write ( single_digits [ num [ x ] - '0' ] + " ▁ " ) ; Console . Write ( tens_power [ len - 3 ] + " ▁ " ) ; } -- len ; } else { if ( num [ x ] - '0' == 1 ) { int sum = num [ x ] - '0' + num [ x + 1 ] - '0' ; Console . WriteLine ( two_digits [ sum ] ) ; return ; } else if ( num [ x ] - '0' == 2 && num [ x + 1 ] - '0' == 0 ) { Console . WriteLine ( " twenty " ) ; return ; } else { int i = ( num [ x ] - '0' ) ; if ( i > 0 ) Console . Write ( tens_multiple [ i ] + " ▁ " ) ; else Console . Write ( " " ) ; ++ x ; if ( num [ x ] - '0' != 0 ) Console . WriteLine ( single_digits [ num [ x ] - '0' ] ) ; } } ++ x ; } } public static void Main ( ) { convert_to_words ( "9923" . ToCharArray ( ) ) ; convert_to_words ( "523" . ToCharArray ( ) ) ; convert_to_words ( "89" . ToCharArray ( ) ) ; convert_to_words ( "8" . ToCharArray ( ) ) ; } }


"Program to convert a given number to words | Set 2 | C # program to print a given number in words . The program handles till 9 digits numbers and can be easily extended to 20 digit number ; strings at index 0 is not used , it is to make array indexing simple ; strings at index 0 and 1 are not used , they is to make array indexing simple ; n is 1 - or 2 - digit number ; if n is more than 19 , divide it ; if n is non - zero ; Function to print a given number in words ; stores word representation of given number n ; handles digits at ten millions and hundred millions places ( if any ) ; handles digits at hundred thousands and one millions places ( if any ) ; handles digits at thousands and tens thousands places ( if any ) ; handles digit at hundreds places ( if any ) ; handles digits at ones and tens places ( if any ) ; Driver code ; long handles upto 9 digit no change to unsigned long long int to handle more digit number ; convert given number in words"
Solution in C#:

using System ; class GFG { static string [ ] one = { " " , " one ▁ " , " two ▁ " , " three ▁ " , " four ▁ " , " five ▁ " , " six ▁ " , " seven ▁ " , " eight ▁ " , " nine ▁ " , " ten ▁ " , " eleven ▁ " , " twelve ▁ " , " thirteen ▁ " , " fourteen ▁ " , " fifteen ▁ " , " sixteen ▁ " , " seventeen ▁ " , " eighteen ▁ " , " nineteen ▁ " } ; static string [ ] ten = { " " , " " , " twenty ▁ " , " thirty ▁ " , " forty ▁ " , " fifty ▁ " , " sixty ▁ " , " seventy ▁ " , " eighty ▁ " , " ninety ▁ " } ; static string numToWords ( int n , string s ) { string str = " " ; if ( n > 19 ) { str += ten [ n / 10 ] + one [ n % 10 ] ; } else { str += one [ n ] ; } if ( n != 0 ) { str += s ; } return str ; } static string convertToWords ( long n ) { string out1 = " " ; out1 += numToWords ( ( int ) ( n / 10000000 ) , " crore ▁ " ) ; out1 += numToWords ( ( int ) ( ( n / 100000 ) % 100 ) , " lakh ▁ " ) ; out1 += numToWords ( ( int ) ( ( n / 1000 ) % 100 ) , " thousand ▁ " ) ; out1 += numToWords ( ( int ) ( ( n / 100 ) % 10 ) , " hundred ▁ " ) ; if ( n > 100 && n % 100 > 0 ) { out1 += " and ▁ " ; } out1 += numToWords ( ( int ) ( n % 100 ) , " " ) ; return out1 ; } static void Main ( ) { long n = 438237764 ; Console . WriteLine ( convertToWords ( n ) ) ; } }


"Program to convert centimeter into meter and kilometer | C # program to convert centimeter into meter and kilometer ; Driver Code ; Converting centimeter into meter and kilometer"
Solution in C#:

using System ; class GFG { static public void Main ( ) { double cm , meter , kilometer ; cm = 1000 ; meter = cm / 100.0 ; kilometer = cm / 100000.0 ; Console . WriteLine ( " Length ▁ in ▁ " + " meter ▁ = ▁ " + meter + " m " ) ; Console . WriteLine ( " Length ▁ in ▁ " + " Kilometer ▁ = ▁ " + kilometer + " km " ) ; } }


"Program to count digits in an integer ( 4 Different Methods ) | C # Code to count number of digits in an integer ; Driver Code"
Solution in C#:

using System ; class GFG { static int countDigit ( long n ) { if ( n / 10 == 0 ) return 1 ; return 1 + countDigit ( n / 10 ) ; } public static void Main ( ) { long n = 345289467 ; Console . WriteLine ( " Number ▁ of ▁ " + " digits ▁ : ▁ " + countDigit ( n ) ) ; } }


"Program to count leaf nodes in a binary tree | C # implementation to find leaf count of a given Binary tree ; Class containing left and right child of current node and key value ; Root of the Binary Tree ; Function to get the count of leaf nodes in a binary tree ; Driver program to test above functions ; create a tree ; get leaf count of the abve tree"
Solution in C#:

using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { public Node root ; public virtual int LeafCount { get { return getLeafCount ( root ) ; } } public virtual int getLeafCount ( Node node ) { if ( node == null ) { return 0 ; } if ( node . left == null && node . right == null ) { return 1 ; } else { return getLeafCount ( node . left ) + getLeafCount ( node . right ) ; } } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; Console . WriteLine ( " The ▁ leaf ▁ count ▁ of ▁ binary ▁ tree ▁ is ▁ : ▁ " + tree . LeafCount ) ; } }


"Program to count occurrence of a given character in a string | package whatever do not write package name here ; base case ; ; checking if the first character of the given string is that character or not ; this will count the occurrence of given character in the string from index 1 to the last index of the string ; Driver code"
Solution in C#:

using System ; public class GFG { static int countinString ( char ch , String s ) { if ( s . Length == 0 ) return 0 ; int count = 0 ; if ( s [ 0 ] == ch ) count ++ ; count += countinString ( ch , s . Substring ( 1 ) ) ; return count ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; char c = ' e ' ; Console . WriteLine ( countinString ( c , str ) ) ; } }


"Program to count vowels , consonant , digits and special characters in string . | Program to count vowels , consonant , digits and special character in a given string ; Function to count number of vowels , consonant , digitsand special character in a string . ; Declare the variable vowels , consonant , digit and special characters ; str . length ( ) function to count number of character in given string . ; To handle upper case letters ; Driver function ."
Solution in C#:

using System ; using System . Globalization ; class GFG { static void countCharacterType ( string str ) { int vowels = 0 , consonant = 0 , specialChar = 0 , digit = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { char ch = str [ i ] ; if ( ( ch >= ' a ' && ch <= ' z ' ) || ( ch >= ' A ' && ch <= ' Z ' ) ) { ch = char . ToLower ( ch ) ; if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) vowels ++ ; else consonant ++ ; } else if ( ch >= '0' && ch <= '9' ) digit ++ ; else specialChar ++ ; } Console . WriteLine ( " Vowels : ▁ " + vowels ) ; Console . WriteLine ( " Consonant : ▁ " + consonant ) ; Console . WriteLine ( " Digit : ▁ " + digit ) ; Console . WriteLine ( " Special ▁ Character : ▁ " + specialChar ) ; } static public void Main ( ) { string str = " geeks ▁ for ▁ geeks121" ; countCharacterType ( str ) ; } }


"Program to count vowels in a string ( Iterative and Recursive ) | C # program to count vowels in a string ; Function to check the Vowel ; Returns count of vowels in str ; Check for vowel ; Driver code ; string object ; Total numbers of Vowel"
Solution in C#:

using System ; class GFG { public static bool isVowel ( char ch ) { ch = char . ToUpper ( ch ) ; return ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) ; } public static int countVowels ( string str ) { int count = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( isVowel ( str [ i ] ) ) { ++ count ; } } return count ; } public static void Main ( string [ ] args ) { string str = " abc ▁ de " ; Console . WriteLine ( countVowels ( str ) ) ; } }


"Program to count vowels in a string ( Iterative and Recursive ) | Recursive C # program to count the total number of vowels using recursion ; Function to check the Vowel ; to count total number of vowel from 0 to n ; Main Calling Function ; string object ; Total numbers of Vowel"
Solution in C#:

using System ; public class GFG { public static int isVowel ( char ch ) { ch = char . ToUpper ( ch ) ; if ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) { return 1 ; } else { return 0 ; } } public static int countVowels ( string str , int n ) { if ( n == 1 ) { return isVowel ( str [ n - 1 ] ) ; } return countVowels ( str , n - 1 ) + isVowel ( str [ n - 1 ] ) ; } public static void Main ( string [ ] args ) { string str = " abc ▁ de " ; Console . WriteLine ( countVowels ( str , str . Length ) ) ; } }


"Program to determine focal length of a spherical mirror | C # program to determine the focal length of a of a spherical mirror ; Determines focal length of a spherical concave mirror ; Determines focal length of a spherical convex mirror ; Driver function"
Solution in C#:

 using System ; class GfG { public static float focal_length_concave ( float R ) { return R / 2 ; } public static float focal_length_convex ( float R ) { return - ( R / 2 ) ; } public static void Main ( String [ ] argc ) { float R = 30 ; Console . Write ( " Focal ▁ length ▁ of " + " spherical ▁ concave " + " mirror ▁ is ▁ : ▁ " + focal_length_concave ( R ) + " ▁ units
 " ) ; Console . Write ( " Focal ▁ length ▁ of " + " spherical ▁ convex " + " mirror ▁ is ▁ : ▁ " + focal_length_convex ( R ) + " ▁ units " ) ; } }


"Program to determine the Quadrant of a Complex number | C # program to determine the quadrant of a complex number ; Function to determine the quadrant of a complex number ; Storing the index of ' + ' ; Storing the index of ' - ' ; Finding the real part of the complex number ; Finding the imaginary part of the complex number ; Driver code"
Solution in C#:

using System ; class GFG { static void quadrant ( String s ) { int l = s . Length ; int i ; if ( s . Contains ( " + " ) ) { i = s . IndexOf ( ' + ' ) ; } else { i = s . IndexOf ( ' - ' ) ; } String real = s . Substring ( 0 , i ) ; String imaginary = s . Substring ( i + 1 , l - 2 - i ) ; int x = Int32 . Parse ( real ) ; int y = Int32 . Parse ( imaginary ) ; if ( x > 0 && y > 0 ) Console . Write ( " Quadrant ▁ 1" ) ; else if ( x < 0 && y > 0 ) Console . Write ( " Quadrant ▁ 2" ) ; else if ( x < 0 && y < 0 ) Console . Write ( " Quadrant ▁ 3" ) ; else if ( x > 0 && y < 0 ) Console . Write ( " Quadrant ▁ 4" ) ; else if ( x == 0 && y > 0 ) Console . Write ( " Lies ▁ on ▁ positive " + " ▁ Imaginary ▁ axis " ) ; else if ( x == 0 && y < 0 ) Console . Write ( " Lies ▁ on ▁ negative " + " ▁ Imaginary ▁ axis " ) ; else if ( y == 0 && x < 0 ) Console . Write ( " Lies ▁ on ▁ negative " + " ▁ X - axis " ) ; else if ( y == 0 && x > 0 ) Console . Write ( " Lies ▁ on ▁ positive " + " ▁ X - axis " ) ; else Console . Write ( " Lies ▁ on ▁ the ▁ Origin " ) ; } public static void Main ( String [ ] args ) { String s = "5 + 3i " ; quadrant ( s ) ; } }


"Program to determine the octant of the axial plane | C # program to print octant of a given point . ; Function to print octant ; Driver Code"
Solution in C#:

using System ; class GFG { static void octant ( float x , float y , float z ) { if ( x >= 0 && y >= 0 && z >= 0 ) Console . WriteLine ( " Point ▁ lies ▁ in ▁ 1st ▁ octant " ) ; else if ( x < 0 && y >= 0 && z >= 0 ) Console . WriteLine ( " Point ▁ lies ▁ in ▁ 2nd ▁ octant " ) ; else if ( x < 0 && y < 0 && z >= 0 ) Console . WriteLine ( " Point ▁ lies ▁ in ▁ 3rd ▁ octant " ) ; else if ( x >= 0 && y < 0 && z >= 0 ) Console . WriteLine ( " Point ▁ lies ▁ in ▁ 4th ▁ octant " ) ; else if ( x >= 0 && y >= 0 && z < 0 ) Console . WriteLine ( " Point ▁ lies ▁ in ▁ 5th ▁ octant " ) ; else if ( x < 0 && y >= 0 && z < 0 ) Console . WriteLine ( " Point ▁ lies ▁ in ▁ 6th ▁ octant " ) ; else if ( x < 0 && y < 0 && z < 0 ) Console . WriteLine ( " Point ▁ lies ▁ in ▁ 7th ▁ octant " ) ; else if ( x >= 0 && y < 0 && z < 0 ) Console . WriteLine ( " Point ▁ lies ▁ in ▁ 8th ▁ octant " ) ; } static public void Main ( ) { float x = 2 , y = 3 , z = 4 ; octant ( x , y , z ) ; x = - 4 ; y = 2 ; z = - 8 ; octant ( x , y , z ) ; x = - 6 ; y = - 2 ; z = 8 ; octant ( x , y , z ) ; } }


"Program to determine the quadrant of the cartesian plane | C # program to check quadrant ; Function to check quadrant ; Driver Code ; Function Calling"
Solution in C#:

using System ; class GFG { static void quadrant ( int x , int y ) { if ( x > 0 && y > 0 ) Console . WriteLine ( " lies ▁ in ▁ First ▁ quadrant " ) ; else if ( x < 0 && y > 0 ) Console . WriteLine ( " lies ▁ in ▁ Second ▁ quadrant " ) ; else if ( x < 0 && y < 0 ) Console . WriteLine ( " lies ▁ in ▁ Third ▁ quadrant " ) ; else if ( x > 0 && y < 0 ) Console . WriteLine ( " lies ▁ in ▁ Fourth ▁ quadrant " ) ; else if ( x == 0 && y > 0 ) Console . WriteLine ( " lies ▁ at ▁ positive ▁ y ▁ axis " ) ; else if ( x == 0 && y < 0 ) Console . WriteLine ( " lies ▁ at ▁ negative ▁ y ▁ axis " ) ; else if ( y == 0 && x < 0 ) Console . WriteLine ( " lies ▁ at ▁ negative ▁ x ▁ axis " ) ; else if ( y == 0 && x > 0 ) Console . WriteLine ( " lies ▁ at ▁ positive ▁ x ▁ axis " ) ; else Console . WriteLine ( " lies ▁ at ▁ origin " ) ; } public static void Main ( ) { int x = 1 , y = 1 ; quadrant ( x , y ) ; } }


"Program to evaluate simple expressions | C # program to evaluate a given expression ; A utility function to check if a given character is operand ; utility function to find value of and operand ; This function evaluates simple expressions . It returns - 1 if the given expression is invalid . ; Base Case : Given expression is empty ; The first character must be an operand , find its value ; Traverse the remaining characters in pairs ; The next character must be an operator , and next to next an operand ; If next to next character is not an operand ; Update result according to the operator ; If not a valid operator ; Driver program to test above function"
Solution in C#:

using System ; class GFG { static bool isOperand ( char c ) { return ( c >= '0' && c <= '9' ) ; } static int value ( char c ) { return ( int ) ( c - '0' ) ; } static int evaluate ( string exp ) { if ( exp . Length == 0 ) return - 1 ; int res = value ( exp [ 0 ] ) ; for ( int i = 1 ; i < exp . Length ; i += 2 ) { char opr = exp [ i ] , opd = exp [ i + 1 ] ; if ( isOperand ( opd ) == false ) return - 1 ; if ( opr == ' + ' ) res += value ( opd ) ; else if ( opr == ' - ' ) res -= value ( opd ) ; else if ( opr == ' * ' ) res *= value ( opd ) ; else if ( opr == ' / ' ) res /= value ( opd ) ; else return - 1 ; } return res ; } static void Main ( ) { string expr1 = "1 + 2*5 + 3" ; int res = evaluate ( expr1 ) ; if ( res == - 1 ) Console . WriteLine ( expr1 + " ▁ is ▁ Invalid " ) ; else Console . WriteLine ( " Value ▁ of ▁ " + expr1 + " ▁ is ▁ " + res ) ; string expr2 = "1 + 2*3" ; res = evaluate ( expr2 ) ; if ( res == - 1 ) Console . WriteLine ( expr2 + " ▁ is ▁ Invalid " ) ; else Console . WriteLine ( " Value ▁ of ▁ " + expr2 + " ▁ is ▁ " + res ) ; string expr3 = "4-2 + 6*3" ; res = evaluate ( expr3 ) ; if ( res == - 1 ) Console . WriteLine ( expr3 + " ▁ is ▁ Invalid " ) ; else Console . WriteLine ( " Value ▁ of ▁ " + expr3 + " ▁ is ▁ " + res ) ; string expr4 = "1 + + 2" ; res = evaluate ( expr4 ) ; if ( res == - 1 ) Console . WriteLine ( expr4 + " ▁ is ▁ Invalid " ) ; else Console . WriteLine ( " Value ▁ of ▁ " + expr4 + " ▁ is ▁ " + res ) ; } }


"Program to evaluate the expression ( ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬ Ãƒ ¢ Ã ¢ â € š ¬ Ã ¢ â € ž ¢ ÃƒÆ ’ Ã † â €™ Ãƒ ¢ Ã ¢ â € š ¬ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒ ¢ Ã ¢ â ‚¬ Å ¾¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ ÃƒÆ ’ Ã † â €™¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â € š ¬ Ã …¡¬ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â € š ¬ Ã …¾¢¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬ Ãƒ ¢ Ã ¢ â € š ¬ Ã ¢ â € ž ¢ ÃƒÆ ’ Ã † â €™ Ãƒ ¢ Ã ¢ â € š ¬ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒ ¢ Ã ¢ â ‚¬ Å ¾¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢¢ ÃƒÆ ’ Ã † â €™¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒâ €¦¡¬¹ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬ Ãƒ ¢ Ã ¢ â € š ¬ Ã ¢ â € ž ¢¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢¢ ÃƒÆ ’ Ã † â €™¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â € š ¬ Ã …¡¬ ÃƒÆ ’ Ã ¢ â ‚¬¦¡¬ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬ Ãƒ ¢ Ã ¢ â € š ¬ Ã ¢ â € ž ¢ ÃƒÆ ’ Ã † â €™ Ãƒ ¢ Ã ¢ â € š ¬ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒ ¢ Ã ¢ â ‚¬ Å ¾¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢¢ ÃƒÆ ’ Ã † â €™¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒâ €¦¡¬¦¡ X + 1 ) ^ 6 + ( ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬ Ãƒ ¢ Ã ¢ â € š ¬ Ã ¢ â € ž ¢ ÃƒÆ ’ Ã † â €™ Ãƒ ¢ Ã ¢ â € š ¬ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒ ¢ Ã ¢ â ‚¬ Å ¾¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ ÃƒÆ ’ Ã † â €™¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â € š ¬ Ã …¡¬ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â € š ¬ Ã …¾¢¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬ Ãƒ ¢ Ã ¢ â € š ¬ Ã ¢ â € ž ¢ ÃƒÆ ’ Ã † â €™ Ãƒ ¢ Ã ¢ â € š ¬ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒ ¢ Ã ¢ â ‚¬ Å ¾¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢¢ ÃƒÆ ’ Ã † â €™¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒâ €¦¡¬¹ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬ Ãƒ ¢ Ã ¢ â € š ¬ Ã ¢ â € ž ¢¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢¢ ÃƒÆ ’ Ã † â €™¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â € š ¬ Ã …¡¬ ÃƒÆ ’ Ã ¢ â ‚¬¦¡¬ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢ ÃƒÆ ’ Ã ¢ â ‚¬ Ãƒ ¢ Ã ¢ â € š ¬ Ã ¢ â € ž ¢ ÃƒÆ ’ Ã † â €™ Ãƒ ¢ Ã ¢ â € š ¬ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒ ¢ Ã ¢ â ‚¬ Å ¾¢ ÃƒÆ ’ Ã † â €™ Ãƒâ € Ã ¢ â ‚¬ â „¢¢ ÃƒÆ ’ Ã † â €™¢ ÃƒÆ ’¢ Ãƒ ¢ Ã ¢ â ‚¬ Å ¡¬ Ãƒâ €¦¡¬¦¡ X | C # program to evaluate the given expression ; Function to..."
Solution in C#:

using System ; class gfg { public static double calculateSum ( double n ) { return 2 * ( Math . Pow ( n , 6 ) + 15 * Math . Pow ( n , 4 ) + 15 * Math . Pow ( n , 2 ) + 1 ) ; } public static int Main ( ) { double n = 1.4142 ; Console . WriteLine ( Math . Ceiling ( calculateSum ( n ) ) ) ; return 0 ; } }


"Program to find Area of Triangle inscribed in N | C # Program to find the area of a triangle inscribed in N - sided regular polygon ; Function to find the area of the polygon ; area of a regular polygon with N sides and side length len ; Function to find the area of a triangle ; area of one triangle in an N - sided regular polygon ; area of inscribed triangle ; Driver code"
Solution in C#:

using System ; class GFG { static double area_of_regular_polygon ( double n , double len ) { double P = ( len * n ) ; double A = len / ( 2 * Math . Tan ( ( 180 / n ) * 3.14159 / 180 ) ) ; double area = ( P * A ) / 2 ; return area ; } static double area_of_triangle_inscribed ( double n , double len ) { double area = area_of_regular_polygon ( n , len ) ; double triangle = area / n ; double ins_tri = ( triangle * 3 ) ; return ins_tri ; } static public void Main ( String [ ] arg ) { double n = 6 , len = 10 ; Console . Write ( " { 0 : F3 } " , area_of_triangle_inscribed ( n , len ) ) ; } }


"Program to find Circumference of a Circle | C # program to find circumference of circle ; utility function ; driver function"
Solution in C#:

using System ; class GFG { static double circumference ( double r ) { double PI = 3.1415 ; double cir = 2 * PI * r ; return cir ; } public static void Main ( ) { double r = 5 ; double result = Math . Round ( circumference ( r ) * 1000 ) / 1000.0 ; Console . WriteLine ( " Circumference ▁ = ▁ " + result ) ; } }


"Program to find GCD of floating point numbers | C # code for finding the GCD of two floating numbers . ; Recursive function to return gcd of a and b ; base case ; Driver Function ."
Solution in C#:

using System ; class GFG { static float gcd ( double a , double b ) { if ( a < b ) return gcd ( b , a ) ; if ( Math . Abs ( b ) < 0.001 ) return ( float ) a ; else return ( float ) ( gcd ( b , a - Math . Floor ( a / b ) * b ) ) ; } public static void Main ( ) { double a = 1.20 , b = 22.5 ; Console . WriteLine ( gcd ( a , b ) ) ; } }


"Program to find GCD or HCF of two numbers | C # program to find GCD of two numbers ; Recursive function to return gcd of a and b ; Driver method"
Solution in C#:

using System ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } public static void Main ( ) { int a = 98 , b = 56 ; Console . WriteLine ( " GCD ▁ of ▁ " + a + " ▁ and ▁ " + b + " ▁ is ▁ " + gcd ( a , b ) ) ; } }


"Program to find GCD or HCF of two numbers | C # program to find GCD of two numbers ; Recursive function to return gcd of a and b ; Everything divides 0 ; base case ; a is greater ; Driver method"
Solution in C#:

using System ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; if ( b == 0 ) return a ; if ( a == b ) return a ; if ( a > b ) return gcd ( a - b , b ) ; return gcd ( a , b - a ) ; } public static void Main ( ) { int a = 98 , b = 56 ; Console . WriteLine ( " GCD ▁ of ▁ " + a + " ▁ and ▁ " + b + " ▁ is ▁ " + gcd ( a , b ) ) ; } }


"Program to find Greatest Common Divisor ( GCD ) of N strings | C # program for the above approach ; Function that finds gcd of 2 strings ; If str1 length is less than that of str2 then recur with gcd ( str2 , str1 ) ; If str1 is not the concatenation of str2 ; GCD string is found ; Cut off the common prefix part of str1 & then recur ; Function to find GCD of array of strings ; Return the GCD of strings ; Driver Code ; Given array of strings ; Function Call"
Solution in C#:

using System ; class GFG { static String gcd ( String str1 , String str2 ) { if ( str1 . Length < str2 . Length ) { return gcd ( str2 , str1 ) ; } else if ( ! str1 . StartsWith ( str2 ) ) { return " " ; } else if ( str2 . Length == 0 ) { return str1 ; } else { return gcd ( str1 . Substring ( str2 . Length ) , str2 ) ; } } static String findGCD ( String [ ] arr , int n ) { String result = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { result = gcd ( result , arr [ i ] ) ; } return result ; } public static void Main ( String [ ] args ) { String [ ] arr = new String [ ] { " GFGGFG " , " GFGGFG " , " GFGGFGGFGGFG " } ; int n = arr . Length ; Console . WriteLine ( findGCD ( arr , n ) ) ; } }


"Program to find HCF ( Highest Common Factor ) of 2 Numbers | C # program to find GCD of two numbers ; Recursive function to return gcd of a and b ; Driver method"
Solution in C#:


"Program to find HCF ( Highest Common Factor ) of 2 Numbers | C # program to find GCD of two numbers ; Recursive function to return gcd of a and b ; Everything divides 0 ; base case ; a is greater ; Driver method"
Solution in C#:

using System ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 && b == 0 ) return 0 ; if ( a == 0 ) return b ; if ( b == 0 ) return a ; if ( a == b ) return a ; if ( a > b ) return gcd ( a - b , b ) ; return gcd ( a , b - a ) ; } public static void Main ( ) { int a = 98 , b = 56 ; Console . WriteLine ( " GCD ▁ of ▁ " + a + " ▁ and ▁ " + b + " ▁ is ▁ " + gcd ( a , b ) ) ; } }


"Program to find LCM of 2 numbers without using GCD | C # program to find LCM of 2 numbers without using GCD ; Function to return LCM of two numbers ; Driver Code"
Solution in C#:

using System ; class GfG { public static int findLCM ( int a , int b ) { int lar = Math . Max ( a , b ) ; int small = Math . Min ( a , b ) ; for ( int i = lar ; ; i += lar ) { if ( i % small == 0 ) return i ; } } public static void Main ( ) { int a = 5 , b = 7 ; Console . WriteLine ( " LCM ▁ of ▁ " + a + " ▁ and ▁ " + b + " ▁ is ▁ " + findLCM ( a , b ) ) ; } }


"Program to find LCM of two Fibonnaci Numbers | C # program to find LCM of Fib ( a ) and Fib ( b ) ; Create an array for memoization ; Function to return the n 'th Fibonacci number using table f[]. ; Base cases ; If fib ( n ) is already computed ; Applying recursive formula Note value n & 1 is 1 if n is odd , else 0. ; Function to return gcd of a and b ; Function to return the LCM of Fib ( a ) and Fib ( a ) ; Driver code"
Solution in C#:

using System ; class GFG { static int MAX = 1000 ; static int [ ] f = new int [ MAX ] ; static int fib ( int n ) { if ( n == 0 ) return 0 ; if ( n == 1 n == 2 ) return ( f [ n ] = 1 ) ; if ( f [ n ] != 0 ) return f [ n ] ; int k = 0 ; if ( ( n & 1 ) != 0 ) k = ( n + 1 ) / 2 ; else k = n / 2 ; if ( ( n & 1 ) != 0 ) f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) ; else f [ n ] = ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int findLCMFibonacci ( int a , int b ) { return ( fib ( a ) * fib ( b ) ) / fib ( gcd ( a , b ) ) ; } static void Main ( ) { int a = 3 , b = 12 ; Console . WriteLine ( findLCMFibonacci ( a , b ) ) ; } }


"Program to find LCM of two numbers | C # program to find LCM of two numbers . ; Recursive method to return gcd of a and b ; method to return LCM of two numbers ; Driver method"
Solution in C#:

using System ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int lcm ( int a , int b ) { return ( a / gcd ( a , b ) ) * b ; } public static void Main ( ) { int a = 15 , b = 20 ; Console . WriteLine ( " LCM ▁ of ▁ " + a + " ▁ and ▁ " + b + " ▁ is ▁ " + lcm ( a , b ) ) ; } }


"Program to find Length of Bridge using Speed and Length of Train | C # Program to implement above code ; function to calculate the length of bridge ; Driver Code ; Assuming the input variables"
Solution in C#:

using System ; class GFG { static int bridge_length ( int trainLength , int Speed , int Time ) { return ( ( Time * Speed ) - trainLength ) ; } static void Main ( ) { int trainLength = 120 ; int Speed = 30 ; int Time = 18 ; Console . Write ( " Length ▁ of ▁ bridge ▁ = ▁ " + bridge_length ( trainLength , Speed , Time ) + " ▁ meters " ) ; } }


"Program to find Length of Latus Rectum of an Ellipse | C # program for the above approach ; Function to calculate the length of the latus rectum of an ellipse ; Length of major axis ; Length of minor axis ; Length of the latus rectum ; Driver Code ; Given lengths of semi - major and semi - minor axis ; Function call to calculate length of the latus rectum of a ellipse"
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 Nth odd Fibonacci Number | C # program for Nth odd fibonacci number ; Function to find nth odd fibonacci number ; Driver Code"
Solution in C#:

using System ; class GFG { static int oddFib ( int n ) { n = ( 3 * n + 1 ) / 2 ; int a = - 1 , b = 1 , c = 0 , i ; for ( i = 1 ; i <= n ; i ++ ) { c = a + b ; a = b ; b = c ; } return c ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . WriteLine ( oddFib ( n ) ) ; } }


"Program to find Nth term divisible by a or b | C # program to find nth term divisible by a or b ; Function to return gcd of a and b ; Function to calculate how many numbers from 1 to num are divisible by a or b ; calculate number of terms divisible by a and by b then , remove the terms which is are divisible by both a and b ; Binary search to find the nth term divisible by a or b ; set low to 1 and high to max ( a , b ) * n , here we have taken high as 10 ^ 18 ; if the current term is less than n then we need to increase low to mid + 1 ; if current term is greater than equal to n then high = mid ; Driver code"
Solution in C#:

using System ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int divTermCount ( int a , int b , int lcm , int num ) { return num / a + num / b - num / lcm ; } static int findNthTerm ( int a , int b , int n ) { int low = 1 , high = int . MaxValue , mid ; int lcm = ( a * b ) / gcd ( a , b ) ; while ( low < high ) { mid = low + ( high - low ) / 2 ; if ( divTermCount ( a , b , lcm , mid ) < n ) low = mid + 1 ; else high = mid ; } return low ; } static public void Main ( ) { int a = 2 , b = 5 , n = 10 ; Console . WriteLine ( findNthTerm ( a , b , n ) ) ; } }


"Program to find Nth term of series 0 , 10 , 30 , 60 , 99 , 150 , 210 , 280. ... ... ... . | C # program to find the N - th term of the series : 0 , 10 , 30 , 60 , 99 , 150 , 210 , ... . . ; calculate Nth term of series ; Driver code"
Solution in C#:

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


"Program to find Nth term of series 0 , 11 , 28 , 51 , 79 , 115 , 156 , 203 , ... . | C # program to find the N - th term of the series : 0 , 11 , 28 , 51 , 79 , 115 , 156 , 203. . ... ; calculate Nth term of series ; Driver code"
Solution in C#:

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


"Program to find Nth term of series 0 , 7 , 18 , 33 , 51 , 75 , 102 , 133 , ... . . | C # program to find the N - th term of the series : 0 , 7 , 18 , 33 , 51 , 75 , 102 , ... . . ; 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 - 3 ; } public static void Main ( ) { int N = 4 ; Console . Write ( nthTerm ( N ) ) ; } }


"Program to find Nth term of series 0 , 9 , 22 , 39 , 60 , 85 , 114 , 147 , ... . . | C # program to find the N - th term of the series : 0 , 9 , 22 , 39 , 60 , 85 , 114 , 147. . ... ; 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 ) + 3 * n - 5 ; } public static void Main ( ) { int N = 4 ; Console . WriteLine ( nthTerm ( N ) ) ; } }


"Program to find Nth term of series 2 , 12 , 28 , 50 , 77 , 112 , 152 , 198 , ... . . | C # program to find the N - th term of the series : 2 , 12 , 28 , 50 , 77 , 112 , 152 , 198 , ... . . ; calculate Nth term of series ; Driver Code"
Solution in C#:

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


"Program to find Nth term of series 3 , 12 , 29 , 54 , 86 , 128 , 177 , 234 , ... . . | C # program to find the N - th term of the series : 3 , 12 , 29 , 54 , 86 , 128 , 177 , 234 , ... ; 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 ) - 3 * n + 2 ; } public static void Main ( ) { int N = 4 ; Console . WriteLine ( nthTerm ( N ) ) ; } }


"Program to find Nth term of series 4 , 14 , 28 , 46 , 68 , 94 , 124 , 158 , ... . . | C # program to find the N - th term of the series : 4 , 14 , 28 , 46 , 68 , 94 , 124 , 158 , ... . . ; 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 ) + 4 * n - 2 ; } public static void Main ( ) { int N = 4 ; Console . Write ( nthTerm ( N ) ) ; } }


"Program to find Nth term of series 9 , 23 , 45 , 75 , 113. . . | C # program to find N - th term of the series : 9 , 23 , 45 , 75 , 113. . . ; 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 ( 2 * N + 3 ) * ( 2 * N + 3 ) - 2 * N ; } public static void Main ( ) { int N = 4 ; Console . WriteLine ( nthTerm ( N ) ) ; } }


"Program to find Nth term of the series 3 , 12 , 29 , 54 , 87 , ... | C # program to find N - th term of the series : 3 , 12 , 29 , 54 , 87 , ... ; calculate Nth term of series ; 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 4 * ( long ) Math . Pow ( N , 2 ) - 3 * N + 2 ; } static public void Main ( ) { long N = 10 ; Console . Write ( getNthTerm ( N ) ) ; } }


"Program to find Perimeter / Circumference of Square and Rectangle | C # program to find Circumference of a square ; Driver Code"
Solution in C#:

using System ; class GFG { static int Circumference ( int a ) { return 4 * a ; } public static void Main ( ) { int a = 5 ; Console . WriteLine ( " Circumference " + " ▁ of ▁ a ▁ square ▁ is ▁ " + Circumference ( a ) ) ; } }


"Program to find Star number | C # program to find star number ; Returns n - th star number ; Driver code"
Solution in C#:

using System ; class GFG { static int findStarNum ( int n ) { return ( 6 * n * ( n - 1 ) + 1 ) ; } public static void Main ( ) { int n = 3 ; Console . Write ( findStarNum ( n ) ) ; } }


"Program to find Sum of a Series a ^ 1 / 1 ! + a ^ 2 / 2 ! + a ^ 3 / 3 ! + a ^ 4 / 4 ! + Ã ¢ â ‚¬¦ Ã ¢ â ‚¬¦ . + a ^ n / n ! | C # program to print the sum of series ; Function to calculate sum of given series ; multiply ( a / i ) to previous term ; store result in res"
Solution in C#:

using System ; class GFG { public static void Main ( ) { double n = 5 , a = 2 ; Console . WriteLine ( sumOfSeries ( a , n ) ) ; } static float sumOfSeries ( double a , double n ) { double res = 0 , prev = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { prev *= ( a / i ) ; res = res + prev ; } return ( float ) ( res ) ; } }


"Program to find Sum of the series 1 * 3 + 3 * 5 + ... . | C # program to find sum of first n terms ; Sn = n * ( 4 * n * n + 6 * n - 1 ) / 3 ; Driver code ; number of terms to be included in the sum ; find the Sn"
Solution in C#:

using System ; class GFG { static int calculateSum ( int n ) { return ( n * ( 4 * n * n + 6 * n - 1 ) / 3 ) ; } static public void Main ( ) { int n = 4 ; Console . WriteLine ( " Sum ▁ = ▁ " + calculateSum ( n ) ) ; } }


"Program to find Surface Area and Volume of Octagonal Prism | C # program to find the surface area and volume of octagonal prism ; Function to find the volume of octagonal prism ; Formula to calculate volume = ( area * h ) ; Display volume ; Function to find the surface area of octagonal prism ; Formula to calculate surface area ; Driver Code"
Solution in C#:

using System ; class GFG { static void find_volume ( double area , double h ) { double Volume = ( area * h ) ; Console . WriteLine ( " Volume : ▁ " + Volume ) ; } static void find_Surface_area ( double area , double a , double h ) { double Surface_area = ( 2 * area ) + ( 8 * a * h ) ; Console . WriteLine ( " Surface ▁ area : ▁ " + Surface_area ) ; } public static void Main ( string [ ] args ) { double h = 1 ; double a = 6 ; double d = 2 ; double area = 2 * a * d ; find_Surface_area ( area , a , h ) ; find_volume ( area , h ) ; } }


"Program to find X , Y and Z intercepts of a plane | C # program to find the X , Y and Z intercepts of a plane ; For finding the x - intercept put y = 0 and z = 0 ; For finding the y - intercept put x = 0 and z = 0 ; For finding the z - intercept put x = 0 and y = 0 ; For Finding value of A , B , C , D ; Calling the first created function ; Driver code"
Solution in C#:

using System ; class GFG { static double [ ] XandYandZintercept ( double A , double B , double C , double D ) { double [ ] rslt = new double [ 3 ] ; double x = - D / A ; double y = - D / B ; double z = - D / C ; rslt [ 0 ] = x ; rslt [ 1 ] = y ; rslt [ 2 ] = z ; return rslt ; } static void equation_plane ( int [ ] p , int [ ] q , int [ ] r ) { int x1 = p [ 0 ] ; int y1 = p [ 1 ] ; int z1 = p [ 2 ] ; int x2 = q [ 0 ] ; int y2 = q [ 1 ] ; int z2 = q [ 2 ] ; int x3 = r [ 0 ] ; int y3 = r [ 1 ] ; int z3 = r [ 2 ] ; int a1 = x2 - x1 ; int b1 = y2 - y1 ; int c1 = z2 - z1 ; int a2 = x3 - x1 ; int b2 = y3 - y1 ; int c2 = z3 - z1 ; int A = ( b1 * c2 - b2 * c1 ) ; int B = ( a2 * c1 - a1 * c2 ) ; int C = ( a1 * b2 - b1 * a2 ) ; int D = ( - A * x1 - B * y1 - C * z1 ) ; double [ ] rslt = XandYandZintercept ( A , B , C , D ) ; for ( int i = 0 ; i < 3 ; i ++ ) { Console . Write ( rslt [ i ] + " ▁ " ) ; } } static void Main ( ) { int x1 = - 1 ; int y1 = 2 ; int z1 = 1 ; int x2 = 0 ; int y2 = - 3 ; int z2 = 2 ; int x3 = 1 ; int y3 = 1 ; int z3 = - 4 ; int [ ] p = { x1 , y1 , z1 } ; int [ ] q = { x2 , y2 , z2 } ; int [ ] r = { x3 , y3 , z3 } ; equation_plane ( p , q , r ) ; } }


"Program to find all Factors of a Number using recursion | C # program to find all the factors of a number using recursion ; Recursive function to print factors of a number ; Checking if the number is less than N ; Calling the function recursively for the next number ; Driver code"
Solution in C#:

using System ; class GFG { static void factors ( int n , int i ) { if ( i <= n ) { if ( n % i == 0 ) { Console . WriteLine ( i + " ▁ " ) ; } factors ( n , i + 1 ) ; } } public static void Main ( ) { int n = 16 ; factors ( n , 1 ) ; } }


"Program to find amount of water in a given glass | Program to find the amount of water in j - th glass of i - th row ; Returns the amount of water in jth glass of ith row ; A row number i has maximum i columns . So input column number must be less than i ; There will be i * ( i + 1 ) / 2 glasses till ith row ( including ith row ) ; Put all water in first glass ; Now let the water flow to the downward glasses till the row number is less than or / equal to i ( given row ) correction : X can be zero for side glasses as they have lower rate to fill ; Fill glasses in a given row . Number of columns in a row is equal to row number ; Get the water from current glass ; Keep the amount less than or equal to capacity in current glass ; Get the remaining amount ; Distribute the remaining amount to the down two glasses ; The index of jth glass in ith row will be i * ( i - 1 ) / 2 + j - 1 ; Driver Code ; Total amount of water"
Solution in C#:

using System ; class GFG { static float findWater ( int i , int j , float X ) { if ( j > i ) { Console . WriteLine ( " Incorrect ▁ Input " ) ; Environment . Exit ( 0 ) ; } int ll = ( int ) Math . Round ( ( double ) ( i * ( i + 1 ) ) ) ; float [ ] glass = new float [ ll + 2 ] ; int index = 0 ; glass [ index ] = X ; for ( int row = 1 ; row <= i ; ++ row ) { for ( int col = 1 ; col <= row ; ++ col , ++ index ) { X = glass [ index ] ; glass [ index ] = ( X >= 1.0f ) ? 1.0f : X ; X = ( X >= 1.0f ) ? ( X - 1 ) : 0.0f ; glass [ index + row ] += X / 2 ; glass [ index + row + 1 ] += X / 2 ; } } return glass [ ( int ) ( i * ( i - 1 ) / 2 + j - 1 ) ] ; } static void Main ( ) { int i = 2 , j = 2 ; float X = 2.0f ; Console . WriteLine ( " Amount ▁ of ▁ water ▁ in ▁ jth ▁ " + " glass ▁ of ▁ ith ▁ row ▁ is : ▁ " + findWater ( i , j , X ) ) ; } }


"Program to find correlation coefficient | C # Program to find correlation coefficient ; function that returns correlation coefficient . ; sum of elements of array X . ; sum of elements of array Y . ; sum of X [ i ] * Y [ i ] . ; sum of square of array elements . ; use formula for calculating correlation coefficient . ; Driver function ; Find the size of array . ; Function call to correlationCoefficient ."
Solution in C#:

using System ; class GFG { static float correlationCoefficient ( int [ ] X , int [ ] Y , int n ) { int sum_X = 0 , sum_Y = 0 , sum_XY = 0 ; int squareSum_X = 0 , squareSum_Y = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum_X = sum_X + X [ i ] ; sum_Y = sum_Y + Y [ i ] ; sum_XY = sum_XY + X [ i ] * Y [ i ] ; squareSum_X = squareSum_X + X [ i ] * X [ i ] ; squareSum_Y = squareSum_Y + Y [ i ] * Y [ i ] ; } float corr = ( float ) ( n * sum_XY - sum_X * sum_Y ) / ( float ) ( Math . Sqrt ( ( n * squareSum_X - sum_X * sum_X ) * ( n * squareSum_Y - sum_Y * sum_Y ) ) ) ; return corr ; } public static void Main ( ) { int [ ] X = { 15 , 18 , 21 , 24 , 27 } ; int [ ] Y = { 25 , 25 , 27 , 31 , 32 } ; int n = X . Length ; Console . Write ( Math . Round ( correlationCoefficient ( X , Y , n ) * 1000000.0 ) / 1000000.0 ) ; } }


"Program to find count of numbers having odd number of divisors in given range | C # implementation of the approach ; Function to return the count of divisors of a number ; Count the powers of the current prime i which divides a ; Update the count of divisors ; Reset the count ; If the remaining a is prime then a ^ 1 will be one of its prime factors ; Function to count numbers having odd number of divisors in range [ A , B ] ; To store the count of elements having odd number of divisors ; Iterate from a to b and find the count of their divisors ; To store the count of divisors of i ; If the divisor count of i is odd ; Driver code"
Solution in C#:

using System ; using System . Collections . Generic ; class GFG { static int divisor ( int a ) { int div = 1 , count = 0 ; for ( int i = 2 ; i <= Math . Sqrt ( a ) ; i ++ ) { while ( a % i == 0 ) { count ++ ; a = a / i ; } div = div * ( count + 1 ) ; count = 0 ; } if ( a > 1 ) { div = div * ( 2 ) ; } return div ; } static int OddDivCount ( int a , int b ) { int res = 0 ; for ( int i = a ; i <= b ; ++ i ) { int divCount = divisor ( i ) ; if ( divCount % 2 == 1 ) { ++ res ; } } return res ; } public static void Main ( String [ ] args ) { int a = 1 , b = 10 ; Console . WriteLine ( OddDivCount ( a , b ) ) ; } }


"Program to find count of numbers having odd number of divisors in given range | C # program to find count of numbers having odd number of divisors in given range ; Function to count numbers having odd number of divisors in range [ A , B ] ; variable to odd divisor count ; iterate from a to b and count their number of divisors ; variable to divisor count ; if count of divisor is odd then increase res by 1 ; Driver code"
Solution in C#:

using System ; class Geeks { static int OddDivCount ( int a , int b ) { int res = 0 ; for ( int i = a ; i <= b ; ++ i ) { int divCount = 0 ; for ( int j = 1 ; j <= i ; ++ j ) { if ( i % j == 0 ) { ++ divCount ; } } if ( ( divCount % 2 ) != 0 ) { ++ res ; } } return res ; } public static void Main ( String [ ] args ) { int a = 1 , b = 10 ; Console . WriteLine ( OddDivCount ( a , b ) ) ; } }


"Program to find equation of a plane passing through 3 points | C # program to find equation of a plane passing through given 3 points . ; Function to find equation of plane . ; Driver code"
Solution in C#:

using System ; class GFG { static void equation_plane ( float x1 , float y1 , float z1 , float x2 , float y2 , float z2 , float x3 , float y3 , float z3 ) { float a1 = x2 - x1 ; float b1 = y2 - y1 ; float c1 = z2 - z1 ; float a2 = x3 - x1 ; float b2 = y3 - y1 ; float c2 = z3 - z1 ; float a = b1 * c2 - b2 * c1 ; float b = a2 * c1 - a1 * c2 ; float c = a1 * b2 - b1 * a2 ; float d = ( - a * x1 - b * y1 - c * z1 ) ; Console . Write ( " equation ▁ of ▁ plane ▁ is ▁ " + a + " x ▁ + ▁ " + b + " y ▁ + ▁ " + c + " z ▁ + ▁ " + d + " ▁ = ▁ 0" ) ; } public static void Main ( ) { float x1 = - 1 ; float y1 = 2 ; float z1 = 1 ; float x2 = 0 ; float y2 = - 3 ; float z2 = 2 ; float x3 = 1 ; float y3 = 1 ; float z3 = - 4 ; equation_plane ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 ) ; } }


"Program to find first N Iccanobif Numbers | C # program to find first N Icanobif numbers ; Iterative function to reverse digits of num ; Function to print first N Icanobif Numbers ; Initialize first , second numbers ; Print first two numbers ; Reversing digit of previous two terms and adding them ; Driver Code"
Solution in C#:

using System ; public class GFG { static int reversDigits ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static void icanobifNumbers ( int N ) { int first = 0 , second = 1 ; if ( N == 1 ) Console . Write ( first ) ; else if ( N == 2 ) Console . Write ( first + " ▁ " + second ) ; else { Console . Write ( first + " ▁ " + second + " ▁ " ) ; for ( int i = 3 ; i <= N ; i ++ ) { int x = reversDigits ( first ) ; int y = reversDigits ( second ) ; Console . Write ( x + y + " ▁ " ) ; int temp = second ; second = x + y ; first = temp ; } } } public static void Main ( ) { int N = 12 ; icanobifNumbers ( N ) ; } }


"Program to find greater value between a ^ n and b ^ n | C # code for finding greater between the a ^ n and b ^ n ; Function to find the greater value ; If n is even ; Driver code"
Solution in C#:

using System ; class GFG { static void findGreater ( int a , int b , int n ) { if ( ! ( ( n & 1 ) > 0 ) ) { a = Math . Abs ( a ) ; b = Math . Abs ( b ) ; } if ( a == b ) Console . WriteLine ( " a ^ n ▁ is ▁ " + " equal ▁ to ▁ b ^ n " ) ; else if ( a > b ) Console . WriteLine ( " a ^ n ▁ is ▁ greater ▁ " + " than ▁ b ^ n " ) ; else Console . WriteLine ( " b ^ n ▁ is ▁ greater ▁ " + " than ▁ a ^ n " ) ; } public static void Main ( ) { int a = 12 , b = 24 , n = 5 ; findGreater ( a , b , n ) ; } }


"Program to find if two numbers and their AM and HM are present in an array using STL | C # program to check if two numbers are present in an array then their AM and HM are also present . Finally , find the GM of the numbers ; Function to find the Arithmetic Mean of 2 numbers ; Function to find the Harmonic Mean of 2 numbers ; Following function checks and computes the desired results based on the means ; Calculate means ; Hash container ( Set ) to store elements HashMap < Double , int > Hash = new HashMap < Double , int > ( ) ; ; Insertion of array elements in the Set ; Conditionals to check if numbers are present in array by Hashing ; Conditionals to check if the AM and HM of the numbers are present in array ; If all conditions are satisfied , the Geometric Mean is calculated ; If numbers are found but the respective AM and HM are not found in the array ; If none of the conditions are satisfied ; Driver code"
Solution in C#:

using System ; using System . Collections . Generic ; class GFG { static Double ArithmeticMean ( Double A , Double B ) { return ( A + B ) / 2 ; } static Double HarmonicMean ( Double A , Double B ) { return ( 2 * A * B ) / ( A + B ) ; } static void CheckArithmeticHarmonic ( Double [ ] arr , Double A , Double B , int N ) { Double AM = ArithmeticMean ( A , B ) ; Double HM = HarmonicMean ( A , B ) ; Dictionary < Double , int > Hash = new Dictionary < Double , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { Hash [ arr [ i ] ] = 1 ; } if ( Hash . ContainsKey ( A ) && Hash . ContainsKey ( B ) ) { if ( Hash . ContainsKey ( AM ) && Hash . ContainsKey ( HM ) ) { Console . Write ( " GM ▁ = ▁ " ) ; Console . Write ( Math . Round ( Math . Sqrt ( AM * HM ) , 2 ) ) ; } else { Console . WriteLine ( " AM ▁ and ▁ HM ▁ not ▁ found " ) ; } } else { Console . WriteLine ( " numbers ▁ not ▁ found " ) ; } } public static void Main ( ) { Double [ ] arr = { 1.0 , 2.0 , 2.5 , 3.0 , 4.0 , 4.5 , 5.0 , 6.0 } ; int N = ( arr . Length ) ; Double A = 3.0 ; Double B = 6.0 ; CheckArithmeticHarmonic ( arr , A , B , N ) ; } }


"Program to find largest element in an array | C # Program to find maximum in arr [ ] ; Method to find maximum in arr [ ] ; Initialize maximum element ; Traverse array elements from second and compare every element with current max ; Driver method"
Solution in C#:

using System ; class GFG { static int [ ] arr = { 10 , 324 , 45 , 90 , 9808 } ; static int largest ( ) { int i ; int max = arr [ 0 ] ; for ( i = 1 ; i < arr . Length ; i ++ ) if ( arr [ i ] > max ) max = arr [ i ] ; return max ; } public static void Main ( ) { Console . WriteLine ( " Largest ▁ in ▁ given ▁ " + " array ▁ is ▁ " + largest ( ) ) ; } }


"Program to find largest element in an array | C # program to find maximum in arr [ ] of size n ; returns maximum in arr [ ] of size n ; Driver code"
Solution in C#:

using System ; using System . Linq ; public class GFG { static int largest ( int [ ] arr , int n ) { return arr . Max ( ) ; } static public void Main ( ) { int [ ] arr = { 10 , 324 , 45 , 90 , 9808 } ; int n = arr . Length ; Console . WriteLine ( largest ( arr , n ) ) ; } }