codeparrot/xlcost-text-to-code huggingface dataset:
Zuckerman Numbers | C # implementation to check if N is a Zuckerman number ; Function to get product of digits ; Function to check if N is an Zuckerman number ; Driver code
using System ; class GFG { static int getProduct ( int n ) { int product = 1 ; while ( n != 0 ) { product = product * ( n % 10 ) ; n = n / 10 ; } return product ; } static bool isZuckerman ( int n ) { return n % getProduct ( n ) == 0 ; } public static void Main ( String [ ] args ) { int n = 115 ; if ( isZuckerman ( n ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }
Additive Prime Number | C # program for the above approach ; Check if N is prime or not ; Corner Cases ; This is checked to skip middle five numbers ; Function to get sum of digits ; Return the sum of digits ; Function to check whether the given number is Additive Prime number or not ; If number is not prime ; Check if sum of digits is prime or not ; Driver code ; Given Number N ; Function Call
using System ; class GFG { static bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static int getSum ( int n ) { int sum = 0 ; while ( n != 0 ) { sum = sum + n % 10 ; n = n / 10 ; } return sum ; } static bool isAdditivePrime ( int n ) { if ( ! isPrime ( n ) ) return false ; return isPrime ( getSum ( n ) ) ; } public static void Main ( ) { int n = 23 ; if ( isAdditivePrime ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }
Straight | C # program for the above approach ; Function to check if N is a Straight Line number or not ; N must be > 99 ; Difference between consecutive digits must be same ; Driver code ; Given Number N ; Function Call
using System ; class GFG { static bool isStraighLineNum ( int N ) { if ( N <= 99 ) return false ; string s = N . ToString ( ) ; int d = s [ 1 ] - s [ 0 ] ; for ( int i = 2 ; i < s . Length ; i ++ ) if ( s [ i ] - s [ i - 1 ] != d ) return false ; return true ; } public static void Main ( ) { int n = 135 ; if ( isStraighLineNum ( n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }
Second | C # implementation to find N - th term in the series ; Function to find N - th term in the series ; Driver code
using System ; class GFG { static void findNthTerm ( int n ) { Console . Write ( Math . Pow ( 2 , n ) - 2 * n ) ; } public static void Main ( ) { int N = 4 ; findNthTerm ( N ) ; } }
Alternating Numbers | C # program for the above approach ; Function to check if a string is of the form even odd even odd ... ; Function to check if a string is of the form odd even odd even ... ; Function to check if n is an alternating number ; Driver Code ; Given number N ; Function call
using System ; class GFG { static bool isEvenOddForm ( String s ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 && s [ i ] % 2 != 0 ) return false ; if ( i % 2 == 1 && s [ i ] % 2 != 1 ) return false ; } return true ; } static bool isOddEvenForm ( String s ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 && s [ i ] % 2 != 1 ) return false ; if ( i % 2 == 1 && s [ i ] % 2 != 0 ) return false ; } return true ; } static bool isAlternating ( int n ) { String str = n . ToString ( ) ; return ( isEvenOddForm ( str ) || isOddEvenForm ( str ) ) ; } public static void Main ( String [ ] args ) { int N = 129 ; if ( isAlternating ( N ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Ormiston prime Pairs | C # implementation to check Ormiston prime ; Function to check if the number is a prime or not ; Corner cases ; This is checked so that we can skip middle five numbers in below loop ; Function to update the frequency array such that freq [ i ] stores the frequency of digit i in n ; While there are digits left to process ; Update the frequency of the current digit ; Remove the last digit ; Function that returns true if a and b are anagrams of each other ; To store the frequencies of the digits in a and b ; Update the frequency of the digits in a ; Update the frequency of the digits in b ; Match the frequencies of the common digits ; If frequency differs for any digit then the numbers are not anagrams of each other ; Returns true if n1 and n2 are Ormiston primes ; Driver code
using System ; class GFG { static bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static int TEN = 10 ; static void updateFreq ( int n , int [ ] freq ) { while ( n > 0 ) { int digit = n % TEN ; freq [ digit ] ++ ; n /= TEN ; } } static bool areAnagrams ( int a , int b ) { int [ ] freqA = new int [ TEN ] ; int [ ] freqB = new int [ TEN ] ; updateFreq ( a , freqA ) ; updateFreq ( b , freqB ) ; for ( int i = 0 ; i < TEN ; i ++ ) { if ( freqA [ i ] != freqB [ i ] ) return false ; } return true ; } static bool OrmistonPrime ( int n1 , int n2 ) { return ( isPrime ( n1 ) && isPrime ( n2 ) && areAnagrams ( n1 , n2 ) ) ; } public static void Main ( String [ ] args ) { int n1 = 1913 , n2 = 1931 ; if ( OrmistonPrime ( n1 , n2 ) ) Console . Write ( " YES " + " STRNEWLINE " ) ; else Console . Write ( " NO " + " STRNEWLINE " ) ; } }
Decakismyriagon Number | C # program for the above approach ; Function to find the N - th Decakismyriagon Number ; Driver code ; Given Number N ; Function Call
using System ; class GFG { static int DecakismyriagonNum ( int N ) { return ( 99998 * N * N - 99996 * N ) / 2 ; } public static void Main ( ) { int N = 3 ; Console . Write ( DecakismyriagonNum ( N ) ) ; } }
Untouchable Number | C # program for the above approach ; Function to calculate sum of all proper divisors of num ; Final result of summation of divisors ; Find all divisors of num ; If ' i ' is divisor of ' num ' ; If both divisors are same then add it only once else add both ; Add 1 to the result as 1 is also a divisor ; Function to check if N is a Untouchable Number ; Driver code ; Given Number N ; Function Call
using System ; class GFG { static int divSum ( int num ) { int result = 0 ; for ( int i = 2 ; i <= Math . Sqrt ( num ) ; i ++ ) { if ( num % i == 0 ) { if ( i == ( num / i ) ) result += i ; else result += ( i + num / i ) ; } } return ( result + 1 ) ; } static bool isUntouchable ( int n ) { for ( int i = 1 ; i <= 2 * n ; i ++ ) { if ( divSum ( i ) == n ) return false ; } return true ; } public static void Main ( ) { int n = 52 ; if ( isUntouchable ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }
Zygodrome Number | C # implementation to check if N is a zygodrome number ; Function to check if N is an zygodrome number ; convert N to string ; Adding a space at the beginning and end of the string ; Traverse the string ; If any character is not same as prev and next then return false ; Driver code
using System ; class GFG { static bool iszygodromeNum ( int N ) { String s = N . ToString ( ) ; s = ' ▁ ' + s + ' ▁ ' ; for ( int i = 1 ; i < s . Length - 1 ; i ++ ) { if ( s [ i ] != s [ i - 1 ] && s [ i ] != s [ i + 1 ] ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { int n = 1122 ; if ( iszygodromeNum ( n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Loeschian Number | C # program for the above approach ; Function to check if N is a Loeschian Number ; Iterate [ 0 , sqrt ( N ) ] for x ; Iterate [ 0 , sqrt ( N ) ] for y ; Check the given criteria ; If no such pair found then return false ; Driver code ; Given Number N ; Function Call
using System ; class GFG { static bool isLoeschian ( int n ) { for ( int x = 1 ; x <= Math . Sqrt ( n ) ; x ++ ) { for ( int y = 1 ; y <= Math . Sqrt ( n ) ; y ++ ) { if ( x * x + x * y + y * y == n ) return true ; } } return false ; } public static void Main ( String [ ] args ) { int n = 19 ; if ( isLoeschian ( n ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }
Admirable Numbers | C # implementation to check if N is a admirable number ; Function to calculate the sum of all divisors of a given number ; Sum of divisors ; Find all divisors which divides ' num ' ; If ' i ' is divisor of ' n ' ; If both divisors are same then add it once else add ; Add 1 and n to result as above loop considers proper divisors greater ; Function to check if there exists a proper divisor D ' ▁ of ▁ N ▁ such ▁ that ▁ sigma ( n ) -2D ' = 2 N ; Find all divisors which divides ' num ' ; If ' i ' is divisor of ' num ' ; If both divisors are same then add it only once else add both ; Check 1 since 1 is also a divisor ; Function to check if N is an admirable number ; Driver code
using System ; class GFG { static int divSum ( int n ) { int result = 0 ; for ( int i = 2 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == ( n / i ) ) result += i ; else result += ( i + n / i ) ; } } return ( result + n + 1 ) ; } static bool check ( int num ) { int sigmaN = divSum ( num ) ; for ( int i = 2 ; i <= Math . Sqrt ( num ) ; i ++ ) { if ( num % i == 0 ) { if ( i == ( num / i ) ) { if ( sigmaN - 2 * i == 2 * num ) return true ; } else { if ( sigmaN - 2 * i == 2 * num ) return true ; if ( sigmaN - 2 * ( num / i ) == 2 * num ) return true ; } } } if ( sigmaN - 2 * 1 == 2 * num ) return true ; return false ; } static bool isAdmirableNum ( int N ) { return check ( N ) ; } public static void Main ( ) { int n = 12 ; if ( isAdmirableNum ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }
Program to print the series 2 , 15 , 41 , 80 , 132 , 197 … till N terms | C # implementation to print the given with the given Nth term ; Function to print the series ; Generate the ith term and ; Driver Code
using System ; class GFG { static void printSeries ( int N ) { int ith_term = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { ith_term = ( 13 * i * ( i - 1 ) ) / 2 + 2 ; Console . Write ( ith_term + " , ▁ " ) ; } } public static void Main ( String [ ] args ) { int N = 7 ; printSeries ( N ) ; } }
Possible pairs forming a Pythagorean Triple with a given value | C # program to compute all the possible pairs that forms a pythagorean triple with a given value ; Function to generate all possible pairs ; List to store all the possible pairs ; Checking all the possible pair in the range of [ 1 , c ) ; If the pair satisfies the condition push it in the vector ; Driver code ; If no valid pair exist ; Print all valid pairs
using System ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static List < pair > Pairs ( int C ) { List < pair > ans = new List < pair > ( ) ; for ( int i = 1 ; i < C ; i ++ ) { for ( int j = i + 1 ; j < C ; j ++ ) { if ( ( i * i ) + ( j * j ) == ( C * C ) ) { ans . Add ( new pair ( i , j ) ) ; } } } return ans ; } public static void Main ( String [ ] args ) { int C = 13 ; List < pair > ans = Pairs ( C ) ; if ( ans . Count == 0 ) { Console . Write ( " No ▁ valid ▁ pair ▁ " + " exist " + " STRNEWLINE " ) ; return ; } foreach ( pair i in ans ) { Console . Write ( " ( " + i . first + " , ▁ " + i . second + " ) " + " STRNEWLINE " ) ; } } }
How to calculate strike rate of a batsman | C # program to calculate strike rate of a batsman ; function to calculate strike rate of a batsman ; Driver Code
using System ; class GFG { static float strikerate ( float bowls , float runs ) { float z ; z = ( runs / bowls ) * 100 ; return z ; } public static void Main ( ) { int A , B ; A = 264 ; B = 173 ; Console . Write ( strikerate ( B , A ) ) ; } }
Check if a number exists with X divisors out of which Y are composite | C # program to check if a number exists having exactly X positive divisors out of which Y are composite divisors ; Count the number of times 2 divides N ; Check for all possible numbers that can divide it ; If N at the end is a prime number . ; Function to check if any such number exists ; Driver code
using System ; class GFG { public static int factorize ( int N ) { int count = 0 ; int cnt = 0 ; while ( ( N % 2 ) == 0 ) { N = N / 2 ; count ++ ; } cnt = cnt + count ; for ( int i = 3 ; i <= Math . Sqrt ( N ) ; i += 2 ) { count = 0 ; while ( N % i == 0 ) { count ++ ; N = N / i ; } cnt = cnt + count ; } if ( N > 2 ) cnt = cnt + 1 ; return cnt ; } public static void ifNumberExists ( int X , int Y ) { int C , dsum ; C = X - Y - 1 ; dsum = factorize ( X ) ; if ( dsum >= C ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } public static void Main ( string [ ] args ) { int X , Y ; X = 6 ; Y = 4 ; ifNumberExists ( X , Y ) ; } }
Nearest prime number in the array of every array element | C # program to find nearest prime number in the array for all array elements ; Create a bool array and set all entries it as false . A value in prime [ i ] will be true if i is not a prime , else false ; Sieve of Eratosthenes function ; Update all multiples of i greater than or equal to the square of it numbers which are multiple of i and are less than i ^ 2 are already been marked . ; Function to find nearest prime number for all elements ; Compute and store all prime numbers up to maxm ; Store the indices of all primes ; If no primes are present in the array ; Store the current prime ; If the no further primes exist in the array ; For all indices less than that of the current prime ; If the current prime is nearer ; If the next prime is nearer ; Make the next prime as the current ; Driver code
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static readonly int max = 10000000 ; static bool [ ] prime = new bool [ max ] ; static void SieveOfEratosthenes ( int maxm ) { prime [ 0 ] = prime [ 1 ] = true ; for ( int i = 2 ; i * i <= maxm ; i ++ ) { if ( ! prime [ i ] ) { for ( int j = i * i ; j <= maxm ; j += i ) { prime [ j ] = true ; } } } } static void print_nearest_prime ( int [ ] arr , int N ) { int maxm = arr . Max ( ) ; SieveOfEratosthenes ( maxm ) ; List < int > primes = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! prime [ arr [ i ] ] ) primes . Add ( i ) ; } if ( primes . Count == 0 ) { for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( - 1 + " ▁ " ) ; } return ; } int curr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( curr == primes . Count - 1 || i <= primes [ curr ] ) { Console . Write ( arr [ primes [ curr ] ] + " ▁ " ) ; continue ; } if ( Math . Abs ( primes [ curr ] - i ) < Math . Abs ( primes [ curr + 1 ] - i ) ) { Console . Write ( arr [ primes [ curr ] ] + " ▁ " ) ; } else { curr ++ ; Console . Write ( arr [ primes [ curr ] ] + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int N = 6 ; int [ ] arr = { 8 , 7 , 12 , 15 , 3 , 11 } ; print_nearest_prime ( arr , N ) ; } }
Find position of given term in a series formed with only digits 4 and 7 allowed | C # program for the above approach ; Function to find the position of the number N ; To store the position of N ; Iterate through all digit of N ; If current digit is 7 ; If current digit is 4 ; Print the final position ; Driver Code ; Given number of the series ; Function Call
using System ; class GFG { static void findPosition ( int n ) { int i = 0 ; int pos = 0 ; while ( n > 0 ) { if ( n % 10 == 7 ) { pos = pos + ( int ) Math . Pow ( 2 , i + 1 ) ; } else { pos = pos + ( int ) Math . Pow ( 2 , i ) ; } i ++ ; n = n / 10 ; } Console . Write ( pos ) ; } public static void Main ( ) { int N = 777 ; findPosition ( N ) ; } }
Average of Cubes of first N natural numbers | C # program for the above approach ; Function to find average of cubes ; Storing sum of cubes of numbers in sum ; Calculate sum of cubes ; Return average ; Driver Code ; Given Number ; Function Call
using System ; class GFG { static double findAverageOfCube ( int n ) { double sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { sum += i * i * i ; } return sum / n ; } public static void Main ( ) { int n = 3 ; Console . Write ( findAverageOfCube ( n ) ) ; } }
Smallest and Largest N | C # program for the above approach ; Function to find n digit largest number starting and ending with n ; Corner Case when n = 1 ; Result will store the n - 2 * length ( n ) digit largest number ; Find the number of digits in number n ; Append 9 ; To make it largest n digit number starting and ending with n , we just need to append n at start and end ; Return the largest number ; Function to find n digit smallest number starting and ending with n ; Corner Case when n = 1 ; Result will store the n - 2 * length ( n ) digit smallest number ; Find the number of digits in number n ; To make it smallest n digit number starting and ending with n , we just need to append n at start and end ; Return the smallest number ; Driver Code ; Given number ; Function call
using System ; class GFG { static String findNumberL ( int n ) { if ( n == 1 ) return "1" ; String result = " " ; int length = ( int ) Math . Floor ( Math . Log10 ( n ) + 1 ) ; for ( int i = 1 ; i <= n - ( 2 * length ) ; i ++ ) { result += '9' ; } result = n . ToString ( ) + result + n . ToString ( ) ; return result ; } static String findNumberS ( int n ) { if ( n == 1 ) return "1" ; String result = " " ; int length = ( int ) Math . Floor ( Math . Log10 ( n ) + 1 ) ; for ( int i = 1 ; i <= n - ( 2 * length ) ; i ++ ) { result += '0' ; } result = n . ToString ( ) + result + n . ToString ( ) ; return result ; } public static void Main ( String [ ] args ) { int N = 3 ; Console . WriteLine ( " Smallest ▁ Number ▁ = ▁ " + findNumberS ( N ) ) ; Console . Write ( " Largest ▁ Number ▁ = ▁ " + findNumberL ( N ) ) ; } }
Maximum number of 0 s that can be flipped such that Array has no adjacent 1 s | C # program for the above approach ; Maximum number of 0 s that can be replaced by 1 ; Check for three consecutive 0 s ; Flip the bit ; Increase the count ; Driver code
using System ; class GFG { public static int canReplace ( int [ ] array ) { int i = 0 , count = 0 ; while ( i < array . Length ) { if ( array [ i ] == 0 && ( i == 0 array [ i - 1 ] == 0 ) && ( i == array . Length - 1 array [ i + 1 ] == 0 ) ) { array [ i ] = 1 ; count ++ ; } i ++ ; } return count ; } public static void Main ( String [ ] args ) { int [ ] array = { 1 , 0 , 0 , 0 , 1 } ; Console . WriteLine ( canReplace ( array ) ) ; } }
Sum of first N Star Numbers | C # program to find the sum of the first N star numbers ; Function to find the sum of the first N star number ; Variable to store the sum ; Driver code
using System ; class GFG { static int sum_star_num ( int n ) { int summ = 2 * n * ( n + 1 ) * ( n - 1 ) + n ; return summ ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( sum_star_num ( n ) ) ; } }
Count distinct median possible for an Array using given ranges of elements | C # implementation to count the number of distinct medians of an array where each array elements are given by a range ; Function to count the number of distinct medians of an array where each array elements are given by a range ; Loop to store the starting and end range in the array ; Condition to check if the length of the array is odd ; Driver code ; Function call
using System ; using System . Collections ; using System . Collections . Generic ; public class Point { public int x , y ; public Point ( int xx , int yy ) { x = xx ; y = yy ; } } class GFG { static void solve ( int n , ArrayList vec ) { ArrayList a = new ArrayList ( ) ; ArrayList b = new ArrayList ( ) ; foreach ( Point pr in vec ) { a . Add ( pr . x ) ; b . Add ( pr . y ) ; } a . Sort ( ) ; b . Sort ( ) ; int left , right , ans ; if ( ( n & 1 ) != 0 ) { left = ( int ) a [ n / 2 ] ; right = ( int ) b [ n / 2 ] ; ans = right - left + 1 ; } else { left = ( ( int ) a [ n / 2 ] + ( int ) a [ n / 2 - 1 ] ) ; right = ( ( int ) b [ n / 2 ] + ( int ) b [ n / 2 - 1 ] ) ; ans = right - left + 1 ; } Console . WriteLine ( ans ) ; } static public void Main ( ) { int N = 3 ; ArrayList vec = new ArrayList ( ) ; vec . Add ( new Point ( 100 , 100 ) ) ; vec . Add ( new Point ( 10 , 10000 ) ) ; vec . Add ( new Point ( 1 , 1000000000 ) ) ; solve ( N , vec ) ; } }
Count of pairs from Array with sum equal to twice their bitwise AND | C # implementation to find the pairs with equal sum and twice the bitwise AND of the pairs ; To store the occurrence of elements of array ; Function to find the pairs with equal sum and twice the bitwise AND of the pairs ; Loop to find the frequency of elements of array ; Function to find the count such pairs in the array ; If an element occurs more than once then the answer will by incremented by nC2 times ; Driver Code ; Function Call
using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; static int find_pairs ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } } foreach ( KeyValuePair < int , int > i in mp ) { int count = i . Value ; if ( count > 1 ) { ans += ( ( count * ( count - 1 ) ) / 2 ) ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 3 , 4 , 5 , 5 , 7 , 8 } ; int arr_size = arr . Length ; Console . Write ( find_pairs ( arr , arr_size ) ) ; } }
360 | C # program for above approach ; Function to find the nth 360 - gon Number ; Driver code
using System ; class GFG { static int gonNum360 ( int n ) { return ( 358 * n * n - 356 * n ) / 2 ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . Write ( gonNum360 ( n ) ) ; } }
120 | C # program for above approach ; Function to find the nth 120 - gon Number ; Driver code
using System ; class GFG { static int gonNum120 ( int n ) { return ( 118 * n * n - 116 * n ) / 2 ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . Write ( gonNum120 ( n ) ) ; } }
Tetracontaoctagonal Number | C # program for above approach ; Function to find the nth TetracontaoctagonalNum Number ; Driver code
using System ; class GFG { static int TetracontaoctagonalNum ( int n ) { return ( 46 * n * n - 44 * n ) / 2 ; } public static void Main ( ) { int n = 3 ; Console . Write ( TetracontaoctagonalNum ( n ) ) ; } }
257 | C # program for above approach ; Function to find the nth 257 - gon Number ; Driver code
using System ; class GFG { static int gonNum257 ( int n ) { return ( 255 * n * n - 253 * n ) / 2 ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . Write ( gonNum257 ( n ) ) ; } }
Tetracontadigonal Number | C # implementation for the above approach ; Function to find the nth Tetracontadigonal Number ; Driver Code
using System ; class GFG { static int TetracontadigonalNum ( int n ) { return ( 40 * n * n - 38 * n ) / 2 ; } public static void Main ( ) { int n = 3 ; Console . Write ( TetracontadigonalNum ( n ) ) ; } }
Index of smallest triangular number with N digits | C # implementation of the above approach ; Function to return index of smallest triangular no n digits ; Driver code
using System ; class GFG { static double findIndex ( int n ) { double x = Math . Sqrt ( 2 * Math . Pow ( 10 , ( n - 1 ) ) ) ; return Math . Round ( x ) ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . Write ( findIndex ( n ) ) ; } }
Program to find the LCM of two prime numbers | C # program to find LCM of two prime numbers ; Function to return the LCM of two prime numbers ; If the two numbers are equal then return any one of a and b ; Else return product of numbers ; Driver code ; Given two numbers ; Function Call
using System ; class GFG { static int findLCMPrime ( int a , int b ) { if ( a == b ) { return a ; } return a * b ; } public static void Main ( string [ ] args ) { int a = 3 , b = 5 ; Console . WriteLine ( findLCMPrime ( a , b ) ) ; } }