codeparrot/xlcost-text-to-code huggingface dataset:
Minimum difference between any two primes from the given range | C # implementation of the approach ; Function for Sieve of Eratosthenes ; Function to return the minimum difference between any two prime numbers from the given range [ L , R ] ; Find the first prime from the range ; Find the second prime from the range ; If the number of primes in the given range is < 2 ; To store the minimum difference between two consecutive primes from the range ; Range left to check for primes ; For every integer in the range ; If the current integer is prime ; If the difference between i and snd is minimum so far ; Driver code ; Generate primes
using System ; class GFG { static int sz = ( int ) 1e5 ; static Boolean [ ] isPrime = new Boolean [ sz + 1 ] ; static void sieve ( ) { for ( int i = 2 ; i < sz + 1 ; i ++ ) isPrime [ i ] = true ; for ( int i = 2 ; i * i <= sz ; i ++ ) { if ( isPrime [ i ] ) { for ( int j = i * i ; j < sz ; j += i ) { isPrime [ j ] = false ; } } } } static int minDifference ( int L , int R ) { int fst = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( isPrime [ i ] ) { fst = i ; break ; } } int snd = 0 ; for ( int i = fst + 1 ; i <= R ; i ++ ) { if ( isPrime [ i ] ) { snd = i ; break ; } } if ( snd == 0 ) return - 1 ; int diff = snd - fst ; int left = snd + 1 ; int right = R ; for ( int i = left ; i <= right ; i ++ ) { if ( isPrime [ i ] ) { if ( i - snd <= diff ) { fst = snd ; snd = i ; diff = snd - fst ; } } } return diff ; } public static void Main ( String [ ] args ) { sieve ( ) ; int L = 21 , R = 50 ; Console . WriteLine ( minDifference ( L , R ) ) ; } }
Number of non | C # implementation of the approach ; Function to return the required count ; To store the final result ; Two pointer loop ; Initialising j ; Looping till the subarray increases ; Update ret ; Update i ; Return ret ; Driver code
using System ; class GFG { static int findCnt ( int [ ] arr , int n , int k ) { int ret = 0 ; int i = 0 ; while ( i < n ) { int j = i + 1 ; while ( j < n && arr [ j ] >= arr [ j - 1 ] ) j ++ ; int x = Math . Max ( 0 , j - i - k + 1 ) ; ret += ( x * ( x + 1 ) ) / 2 ; i = j ; } return ret ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 4 , 3 , 2 , 1 } ; int n = arr . Length ; int k = 2 ; Console . WriteLine ( findCnt ( arr , n , k ) ) ; } }
Count of elements which are second smallest among three consecutive elements | C # implementation of the approach ; Function to return the count of elements P [ i ] such that P [ i ] is the second smallest among P [ i - 1 ] , P [ i ] and P [ i + 1 ] ; To store the required answer ; Traverse from the second element to the second last element ; Return the required answer ; Driver code
using System ; class GFG { static int countElements ( int [ ] p , int n ) { int ans = 0 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( p [ i - 1 ] > p [ i ] && p [ i ] > p [ i + 1 ] ) ans ++ ; else if ( p [ i - 1 ] < p [ i ] && p [ i ] < p [ i + 1 ] ) ans ++ ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] p = { 2 , 5 , 1 , 3 , 4 } ; int n = p . Length ; Console . WriteLine ( countElements ( p , n ) ) ; } }
Count integers in the range [ A , B ] that are not divisible by C and D | C # implementation of the approach ; Function to return the count of integers from the range [ a , b ] that are not divisible by c and d ; Numbers which are divisible by c ; Numbers which are divisible by d ; Find lowest common factor of c and d ; Numbers which are divisible by both c and d ; Return the required answer ; Driver code
using System ; class GFG { static int countNums ( int a , int b , int c , int d ) { int x = b / c - ( a - 1 ) / c ; int y = b / d - ( a - 1 ) / d ; int k = ( c * d ) / __gcd ( c , d ) ; int z = b / k - ( a - 1 ) / k ; return b - a + 1 - x - y + z ; } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int a = 10 , b = 50 , c = 4 , d = 6 ; Console . WriteLine ( countNums ( a , b , c , d ) ) ; } }
Number of non | C # implementation of the approach ; Function to return the count of increasing subarrays of length k ; To store the final result ; Two pointer loop ; Initialising j ; Looping till the subarray increases ; Updating the required count ; Updating i ; Returning res ; Driver code
using System ; class GFG { static int cntSubArrays ( int [ ] arr , int n , int k ) { int res = 0 ; int i = 0 ; while ( i < n ) { int j = i + 1 ; while ( j < n && arr [ j ] >= arr [ j - 1 ] ) j ++ ; res += Math . Max ( j - i - k + 1 , 0 ) ; i = j ; } return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 2 , 5 } ; int n = arr . Length ; int k = 2 ; Console . WriteLine ( cntSubArrays ( arr , n , k ) ) ; } }
Longest sub | C # implementation of the approach ; Function to return the length of the largest subsequence with minimum possible LCM ; Minimum value from the array ; To store the frequency of the minimum element in the array ; If current element is equal to the minimum element ; Driver code
using System ; using System . Linq ; class GFG { static int maxLen ( int [ ] arr , int n ) { int min_val = arr . Min ( ) ; int freq = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == min_val ) freq ++ ; } return freq ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 1 } ; int n = arr . Length ; Console . WriteLine ( maxLen ( arr , n ) ) ; } }
Program to find the last digit of X in base Y | C # Program to find the last digit of X in base Y ; Function to find the last digit of X in base Y ; Driver code
using System ; class GFG { static void last_digit ( int X , int Y ) { Console . Write ( X % Y ) ; } public static void Main ( String [ ] args ) { int X = 55 , Y = 3 ; last_digit ( X , Y ) ; } }
Count of squares that can be drawn without lifting the pencil | C # implementation of the approach ; Function to return the count of squares that can be formed ; Driver code
using System ; class GFG { static int countSquares ( int n ) { return ( int ) ( Math . Pow ( n , 2 ) - ( 2 * n ) + 2 ) ; } public static void Main ( String [ ] args ) { int n = 2 ; Console . WriteLine ( countSquares ( n ) ) ; } }
Integer part of the geometric mean of the divisors of N | C # implementation of the approach ; Function to return the integer part of the geometric mean of the divisors of n ; Driver code
using System ; class GFG { static int geometricMean ( int n ) { return ( int ) Math . Sqrt ( n ) ; } public static void Main ( String [ ] args ) { int n = 16 ; Console . WriteLine ( geometricMean ( n ) ) ; } }
Number of K 's such that the given array can be divided into two sets satisfying the given conditions | C # implementation of the approach ; Function to return the count of K 's such that the array can be divided into two sets containing equal number of elements when all the elements less than K are in one set and the rest of the elements are in the other set ; Sort the given array ; Return number of such Ks ; Driver code
using System ; class GFG { static int two_sets ( int [ ] a , int n ) { Array . Sort ( a ) ; return a [ n / 2 ] - a [ ( n / 2 ) - 1 ] ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 4 , 4 , 6 , 7 , 9 } ; int n = a . Length ; Console . WriteLine ( two_sets ( a , n ) ) ; } }
Count of pairs in an array such that the highest power of 2 that divides their product is 1 | C # implementation of the approach ; Function to return the count of valid pairs ; To store the count of odd numbers and the count of even numbers such that 2 is the only even factor of that number ; If current number is odd ; If current number is even and 2 is the only even factor of it ; Calculate total number of valid pairs ; Driver code
using System ; class GFG { static int cntPairs ( int [ ] a , int n ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 1 ) odd ++ ; else if ( ( a [ i ] / 2 ) % 2 == 1 ) even ++ ; } int ans = odd * even + ( odd * ( odd - 1 ) ) / 2 ; return ans ; } public static void Main ( String [ ] args ) { int [ ] a = { 4 , 2 , 7 , 11 , 14 , 15 , 18 } ; int n = a . Length ; Console . WriteLine ( cntPairs ( a , n ) ) ; } }
Make the array non | C # implementation of the approach ; Function to make array non - decreasing ; Take the first element ; Perform the operation ; Traverse the array ; Next element ; If next element is greater than the current element then decrease it to increase the possibilities ; It is not possible to make the array non - decreasing with the given operation ; Next element is now the current ; The array can be made non - decreasing with the given operation ; Driver code
using System ; class GFG { static Boolean isPossible ( int [ ] a , int n ) { int cur = a [ 0 ] ; cur -- ; for ( int i = 1 ; i < n ; i ++ ) { int nxt = a [ i ] ; if ( nxt > cur ) nxt -- ; else if ( nxt < cur ) return false ; cur = nxt ; } return true ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 1 , 2 , 3 } ; int n = a . Length ; if ( isPossible ( a , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Find the maximum element in the array other than Ai | C # implementation of the approach ; Function to find maximum element among ( N - 1 ) elements other than a [ i ] for each i from 1 to N ; To store prefix max element ; To store suffix max element ; Find the maximum element in the array other than a [ i ] ; Driver code
using System ; class GFG { static void max_element ( int [ ] a , int n ) { int [ ] pre = new int [ n ] ; pre [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) pre [ i ] = Math . Max ( pre [ i - 1 ] , a [ i ] ) ; int [ ] suf = new int [ n ] ; suf [ n - 1 ] = a [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) suf [ i ] = Math . Max ( suf [ i + 1 ] , a [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) Console . Write ( suf [ i + 1 ] + " ▁ " ) ; else if ( i == n - 1 ) Console . Write ( pre [ i - 1 ] + " ▁ " ) ; else Console . Write ( Math . Max ( pre [ i - 1 ] , suf [ i + 1 ] ) + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 5 , 6 , 1 , 3 } ; int n = a . Length ; max_element ( a , n ) ; } }
Find the Kth position element of the given sequence | C # implementation of the approach ; Function to return the kth number from the required sequence ; Count of odd integers in the sequence ; kth number is even ; It is odd ; Driver code
using System ; class GFG { static int kthNum ( int n , int k ) { int a = ( n + 1 ) / 2 ; if ( k > a ) return ( 2 * ( k - a ) ) ; return ( 2 * k - 1 ) ; } public static void Main ( String [ ] args ) { int n = 7 , k = 7 ; Console . WriteLine ( kthNum ( n , k ) ) ; } }
Find K such that | A | C # implementation of the approach ; Function to find k such that | a - k | = | b - k | ; If ( a + b ) is even ; Driver code
using System ; class GFG { static int find_k ( int a , int b ) { if ( ( a + b ) % 2 == 0 ) return ( ( a + b ) / 2 ) ; return - 1 ; } public static void Main ( ) { int a = 2 , b = 16 ; Console . Write ( find_k ( a , b ) ) ; } }
Increasing permutation of first N natural numbers | C # implementation of the approach ; Function that returns true if it is possible to make the permutation increasing by swapping any two numbers ; To count misplaced elements ; Count all misplaced elements ; If possible ; Driver code
using System ; class GFG { static Boolean isPossible ( int [ ] a , int n ) { int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] != i + 1 ) k ++ ; } if ( k <= 2 ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] a = { 5 , 2 , 3 , 4 , 1 } ; int n = a . Length ; if ( isPossible ( a , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Find the number of positive integers less than or equal to N that have an odd number of digits | C # implementation of the approach ; Function to return the number of positive integers less than or equal to N that have odd number of digits ; Driver code
using System ; class GFG { static int odd_digits ( int n ) { if ( n < 10 ) return n ; else if ( n / 10 < 10 ) return 9 ; else if ( n / 100 < 10 ) return 9 + n - 99 ; else if ( n / 1000 < 10 ) return 9 + 900 ; else if ( n / 10000 < 10 ) return 909 + n - 9999 ; else return 90909 ; } public static void Main ( String [ ] args ) { int n = 893 ; Console . WriteLine ( odd_digits ( n ) ) ; } }
Count of N | C # implementation of the approach ; Function to return the count of N - digit palindrome numbers ; Driver code
using System ; class GFG { static int nDigitPalindromes ( int n ) { return ( 9 * ( int ) Math . Pow ( 10 , ( n - 1 ) / 2 ) ) ; } public static void Main ( String [ ] args ) { int n = 2 ; Console . WriteLine ( nDigitPalindromes ( n ) ) ; } }
Maximum LCM among all pairs ( i , j ) of first N natural numbers | C # implementation of the approach ; Function to return the maximum LCM among all the pairs ( i , j ) of first n natural numbers ; Driver code
using System ; class GFG { static int maxLCM ( int n ) { return ( n * ( n - 1 ) ) ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( maxLCM ( n ) ) ; } }
Sum of all the numbers in the Nth row of the given triangle | C # implementation of the approach ; Function to return the sum of the nth row elements of the given triangle ; Driver code
using System ; class GFG { static int getSum ( int n ) { return ( ( n - 1 ) + ( int ) Math . Pow ( n , 2 ) ) ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( getSum ( n ) ) ; } }
Number of edges in a perfect binary tree with N levels | C # implementation of the approach ; Function to return the count of edges in an n - level perfect binary tree ; Driver code
using System ; class GFG { static int cntEdges ( int n ) { int edges = ( int ) Math . Pow ( 2 , n ) - 2 ; return edges ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . Write ( cntEdges ( n ) ) ; } }
Number of cells in the Nth order figure | C # implementation of the approach ; Function to return the number of cells in the nth order figure of the given type ; Driver code
using System ; class GFG { static int cntCells ( int n ) { int cells = ( int ) Math . Pow ( n , 2 ) + ( int ) Math . Pow ( n - 1 , 2 ) ; return cells ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( cntCells ( n ) ) ; } }
Sum of all the numbers in the Nth parenthesis | C # implementation of the approach ; Function to return the sum of the numbers in the nth parenthesis ; Driver code
using System ; class GFG { static int findSum ( int n ) { return ( int ) Math . Pow ( n , 3 ) ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( findSum ( n ) ) ; } }
Find the count of natural Hexadecimal numbers of size N | C # implementation of the approach ; Function to return the count of n - digit natural hexadecimal numbers ; Driver code
using System ; class GFG { static int count ( int n ) { return ( int ) ( 15 * Math . Pow ( 16 , n - 1 ) ) ; } public static void Main ( String [ ] args ) { int n = 2 ; Console . WriteLine ( count ( n ) ) ; } }
Largest Even and Odd N | C # implementation of the approach ; Function to print the largest n - digit even and odd numbers in octal number system ; Append '7' ( N - 1 ) times ; Append '6' for an even number ; Append '7' for an odd number ; Driver code
using System ; class GFG { static void findNumbers ( int n ) { String ans = " " ; for ( int i = 0 ; i < n - 1 ; i ++ ) ans += '7' ; String even = ans + '6' ; String odd = ans + '7' ; Console . WriteLine ( " Even ▁ : ▁ " + even ) ; Console . WriteLine ( " Odd ▁ : ▁ " + odd ) ; } public static void Main ( String [ ] args ) { int n = 4 ; findNumbers ( n ) ; } }
Nth term of a Custom Fibonacci series | C # implementation of the Custom Fibonacci series ; Function to return the nth term of the required sequence ; Driver code
using System ; class GFG { static int nth_term ( int a , int b , int n ) { int z = 0 ; if ( n % 6 == 1 ) z = a ; else if ( n % 6 == 2 ) z = b ; else if ( n % 6 == 3 ) z = b - a ; else if ( n % 6 == 4 ) z = - a ; else if ( n % 6 == 5 ) z = - b ; if ( n % 6 == 0 ) z = - ( b - a ) ; return z ; } static public void Main ( ) { int a = 10 , b = 17 , n = 3 ; Console . Write ( nth_term ( a , b , n ) ) ; } }
Check whether the given integers a , b , c and d are in proportion | C # implementation of the approach ; Function that returns true if the given four integers are in proportion ; Array will consist of only four integers ; Sort the array ; Find the product of extremes and means ; If the products are equal ; Driver code
using System ; class GFG { static bool inProportion ( int [ ] arr ) { int n = 4 ; Array . Sort ( arr ) ; long extremes = ( long ) arr [ 0 ] * ( long ) arr [ 3 ] ; long means = ( long ) arr [ 1 ] * ( long ) arr [ 2 ] ; if ( extremes == means ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 2 } ; if ( inProportion ( arr ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Find the deleted value from the array when average of original elements is given | C # implementation of above approach ; Function to return the missing element ; Find the sum of the array elements ; The numerator and the denominator of the equation ; If not divisible then X is not an integer it is a floating point number ; Return X ; Driver code
using System ; class GFG { static int findMissing ( int [ ] arr , int n , int k , int avg ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; } int num = ( avg * ( n + k ) ) - sum ; int den = k ; if ( num % den != 0 ) return - 1 ; return ( int ) ( num / den ) ; } public static void Main ( String [ ] args ) { int k = 3 , avg = 4 ; int [ ] arr = { 2 , 7 , 3 } ; int n = arr . Length ; Console . WriteLine ( findMissing ( arr , n , k , avg ) ) ; } }
Count of N | C # implementation of the approach ; Function to return the factorial of n ; Function to return the count of n - digit numbers with all distinct digits ; Driver code
using System ; class GFG { static int factorial ( int n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } static int countNum ( int n ) { if ( n > 10 ) return 0 ; return ( 9 * factorial ( 9 ) / factorial ( 10 - n ) ) ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( countNum ( n ) ) ; } }
Maximum number of distinct positive integers that can be used to represent N | C # implementation of approach ; Function to return the required count ; Driver Code
using System ; class GFG { public static int count ( int n ) { return ( - 1 + ( int ) Math . Sqrt ( 1 + 8 * n ) ) / 2 ; } public static void Main ( ) { int n = 10 ; Console . Write ( count ( n ) ) ; } }
Find the previous fibonacci number | C # implementation of the approach ; Function to return the previous fibonacci number ; Driver code
using System ; class GFG { static int previousFibonacci ( int n ) { double a = n / ( ( 1 + Math . Sqrt ( 5 ) ) / 2.0 ) ; return ( int ) Math . Round ( a ) ; } public static void Main ( ) { int n = 8 ; Console . Write ( previousFibonacci ( n ) ) ; } }
Find the quadratic equation from the given roots | C # implementation of the above approach ; Function to find the quadratic equation whose roots are a and b ; Driver code
using System ; class GFG { static void findEquation ( int a , int b ) { int sum = ( a + b ) ; int product = ( a * b ) ; Console . WriteLine ( " x ^ 2 ▁ - ▁ ( " + sum + " x ) ▁ + ▁ ( " + product + " ) ▁ = ▁ 0" ) ; } public static void Main ( ) { int a = 2 , b = 3 ; findEquation ( a , b ) ; } }
Smallest N digit number which is a perfect fourth power | C # implementation of the approach ; Function to return the smallest n - digit number which is a perfect fourth power ; Driver code
using System ; class GFG { static int cal ( int n ) { double res = Math . Pow ( Math . Ceiling ( ( Math . Pow ( Math . Pow ( 10 , ( n - 1 ) ) , 1 / 4 ) ) ) , 4 ) ; return ( int ) res ; } public static void Main ( ) { int n = 1 ; Console . Write ( cal ( n ) ) ; } }
Count of 0 s in an N | C # implementation of the approach ; Function to return the count of 0 s in an n - level hexagon ; Driver code
using System ; class GFG { static int count ( int n ) { return 3 * n * ( n - 1 ) + 1 ; } static public void Main ( ) { int n = 3 ; Console . Write ( count ( n ) ) ; } }
Number of words that can be made using exactly P consonants and Q vowels from the given string | C # implementation of the approach ; Function to return the value of nCk ; Function to return the factorial of n ; Function that returns true if ch is a vowel ; Function to return the number of words possible ; To store the count of vowels and consonanats in the given string ; If current character is a vowel ; Find the total possible words ; Driver code
using System ; using System . Collections . Generic ; class GFG { static long binomialCoeff ( long n , long k ) { if ( k == 0 k == n ) return 1 ; return binomialCoeff ( n - 1 , k - 1 ) + binomialCoeff ( n - 1 , k ) ; } static long fact ( long n ) { if ( n >= 1 ) return n * fact ( n - 1 ) ; else return 1 ; } static bool isVowel ( char ch ) { if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) { return true ; } return false ; } static long countWords ( String s , int p , int q ) { long countc = 0 , countv = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( isVowel ( s [ i ] ) ) countv ++ ; else countc ++ ; } long a = binomialCoeff ( countc , p ) ; long b = binomialCoeff ( countv , q ) ; long c = fact ( p + q ) ; long ans = ( a * b ) * c ; return ans ; } public static void Main ( String [ ] args ) { String s = " crackathon " ; int p = 4 , q = 3 ; Console . WriteLine ( countWords ( s , p , q ) ) ; } }
Count of elements on the left which are divisible by current element | C # implementation of above approach ; Utility function to print the elements of the array ; Function to generate and print the required array ; For every element of the array ; To store the count of elements on the left that the current element divides ; Print the generated array ; Driver code
using System ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void generateArr ( int [ ] A , int n ) { int [ ] B = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < i ; j ++ ) { if ( A [ j ] % A [ i ] == 0 ) cnt ++ ; } B [ i ] = cnt ; } printArr ( B , n ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 3 , 5 , 1 } ; int n = A . Length ; generateArr ( A , n ) ; } }
Represent the given number as the sum of two composite numbers | C # implementation of the approach ; Function to find two composite numbers which when added give sum as n ; Only 8 and 10 can be represented as the sum of two composite integers ; If n is even ; If n is odd ; Driver code
using System ; class GFG { static void findNums ( int n ) { if ( n <= 11 ) { if ( n == 8 ) Console . Write ( "4 ▁ 4" ) ; if ( n == 10 ) Console . Write ( "4 ▁ 6" ) ; else Console . Write ( " - 1" ) ; return ; } if ( n % 2 == 0 ) Console . Write ( "4 ▁ " + ( n - 4 ) ) ; else Console . Write ( "9 ▁ " + ( n - 9 ) ) ; } public static void Main ( ) { int n = 13 ; findNums ( n ) ; } }
Count of N | C # implementation of the approach ; Function to return the count of possible numbers ; Driver code
using System ; class GFG { static int count ( int n ) { return ( int ) Math . Pow ( 2 , n - 1 ) ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . WriteLine ( count ( n ) ) ; } }
Find the next fibonacci number | C # implementation of the approach ; Function to return the next fibonacci number ; Driver code
using System ; class GFG { static long nextFibonacci ( int n ) { double a = n * ( 1 + Math . Sqrt ( 5 ) ) / 2.0 ; return ( long ) Math . Round ( a ) ; } public static void Main ( String [ ] args ) { int n = 5 ; Console . WriteLine ( nextFibonacci ( n ) ) ; } }
Sum of all the numbers present at given level in Pascal 's triangle | C # implementation of the approach ; Function to find sum of numbers at Lth level in Pascals Triangle ; Driver Code
using System ; class GFG { static int sum ( int h ) { return ( int ) Math . Pow ( 2 , h - 1 ) ; } public static void Main ( ) { int L = 3 ; Console . WriteLine ( sum ( L ) ) ; } }