codeparrot/xlcost-text-to-code huggingface dataset:
Composite numbers with digit sum 1 | C # implementation of the above approach ; Function that returns true if number n is a composite number ; Corner cases ; This is checked so that we can skip middle five numbers in below loop ; Function that returns true if the eventual digit sum of number nm is 1 ; Loop till the sum is not single digit number ; Intitialize the sum as zero ; Find the sum of digits ; If sum is eventually 1 ; Function to print the required numbers from the given range ; If i is one of the required numbers ; Driver code
using System ; class GFG { static bool isComposite ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } static bool isDigitSumOne ( int nm ) { while ( nm > 9 ) { int sum_digit = 0 ; while ( nm > 0 ) { int digit = nm % 10 ; sum_digit = sum_digit + digit ; nm = nm / 10 ; } nm = sum_digit ; } if ( nm == 1 ) return true ; else return false ; } static void printValidNums ( int l , int r ) { for ( int i = l ; i <= r ; i ++ ) { if ( isComposite ( i ) && isDigitSumOne ( i ) ) Console . Write ( i + " ▁ " ) ; } } static public void Main ( ) { int l = 10 , r = 100 ; printValidNums ( l , r ) ; } }
Determine the count of Leaf nodes in an N | C # program to find number of leaf nodes ; Function to calculate leaf nodes in n - ary tree ; Driver code
using System ; class GFG { static int calcNodes ( int N , int I ) { int result = 0 ; result = I * ( N - 1 ) + 1 ; return result ; } public static void Main ( ) { int N = 5 , I = 2 ; Console . Write ( " Leaf ▁ nodes ▁ = ▁ " + calcNodes ( N , I ) ) ; } }
An application on Bertrand 's ballot theorem | C # implementation of the approach ; Function to calculate factorial of a number mod 1000000007 ; Factorial of i = factorial of ( i - 1 ) * i ; ; Taking mod along with calculation . ; Function for modular exponentiation ; If p is odd ; If p is even ; Function to return the count of required permutations ; Calculating multiplicative modular inverse for x ! and multiplying with ans ; Calculating multiplicative modular inverse for y ! and multiplying with ans ; Driver code ; Pre - compute factorials
class GFG { static long mod = 1000000007 ; static long [ ] arr = new long [ 1000001 ] ; static void cal_factorial ( ) { arr [ 0 ] = 1 ; for ( long i = 1 ; i <= 1000000 ; i ++ ) { arr [ i ] = ( arr [ i - 1 ] * i ) % mod ; } } static long mod_exponent ( long num , long p ) { if ( p == 0 ) return 1 ; if ( ( p & 1 ) != 0 ) { return ( ( num % mod ) * ( mod_exponent ( ( num * num ) % mod , p / 2 ) ) % mod ) % mod ; } else return ( mod_exponent ( ( num * num ) % mod , p / 2 ) ) % mod ; } static long getCount ( long x , long y ) { long ans = arr [ x + y - 1 ] ; ans *= mod_exponent ( arr [ x ] , mod - 2 ) ; ans %= mod ; ans *= mod_exponent ( arr [ y ] , mod - 2 ) ; ans %= mod ; ans *= ( x - y ) ; ans %= mod ; return ans ; } static void Main ( ) { cal_factorial ( ) ; long x = 3 , y = 1 ; System . Console . WriteLine ( getCount ( x , y ) ) ; } }
Find the values of X and Y in the Given Equations | C # program to find the values of X and Y using the given equations ; Function to find the values of X and Y ; base condition ; required answer ; Driver Code
using System ; class GFG { static void findValues ( int a , int b ) { if ( ( a - b ) % 2 == 1 ) { Console . Write ( " - 1" ) ; return ; } Console . WriteLine ( ( ( a - b ) / 2 ) + " ▁ " + ( ( a + b ) / 2 ) ) ; } static public void Main ( ) { int a = 12 , b = 8 ; findValues ( a , b ) ; } }
Program to implement Inverse Interpolation using Lagrange Formula | C # code for solving inverse interpolation ; Consider a structure to keep each pair of x and y together ; Function to calculate the inverse interpolation ; Initialize readonly x ; Calculate each term of the given formula ; Add term to readonly result ; Driver Code ; Sample dataset of 4 points Here we find the value of x when y = 4.5 ; Size of dataset ; Sample y value ; Using the Inverse Interpolation function to find the value of x when y = 4.5
using System ; class GFG { class Data { public double x , y ; public Data ( double x , double y ) { this . x = x ; this . y = y ; } } ; static double inv_interpolate ( Data [ ] d , int n , double y ) { double x = 0 ; int i , j ; for ( i = 0 ; i < n ; i ++ ) { double xi = d [ i ] . x ; for ( j = 0 ; j < n ; j ++ ) { if ( j != i ) { xi = xi * ( y - d [ j ] . y ) / ( d [ i ] . y - d [ j ] . y ) ; } } x += xi ; } return x ; } public static void Main ( String [ ] args ) { Data [ ] d = { new Data ( 1.27 , 2.3 ) , new Data ( 2.25 , 2.95 ) , new Data ( 2.5 , 3.5 ) , new Data ( 3.6 , 5.1 ) } ; int n = 4 ; double y = 4.5 ; Console . Write ( " Value ▁ of ▁ x ▁ at ▁ y ▁ = ▁ 4.5 ▁ : ▁ { 0 : f5 } " , inv_interpolate ( d , n , y ) ) ; } }
Count triplet pairs ( A , B , C ) of points in 2 | C # implementation of the approach ; Function to return the count of possible triplets ; Insert all the points in a set ; If the mid point exists in the set ; Return the count of valid triplets ; Driver code
using System ; using System . Collections . Generic ; class GFG { public class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int countTriplets ( int n , List < pair > points ) { HashSet < pair > pts = new HashSet < pair > ( ) ; int ct = 0 ; for ( int i = 0 ; i < n ; i ++ ) pts . Add ( points [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) { int x = points [ i ] . first + points [ j ] . first ; int y = points [ i ] . second + points [ j ] . second ; if ( x % 2 == 0 && y % 2 == 0 ) if ( ! pts . Contains ( new pair ( x / 2 , y / 2 ) ) ) ct ++ ; } return ct ; } public static void Main ( String [ ] args ) { List < pair > points = new List < pair > ( ) ; points . Add ( new pair ( 1 , 1 ) ) ; points . Add ( new pair ( 2 , 2 ) ) ; points . Add ( new pair ( 3 , 3 ) ) ; int n = points . Count ; Console . WriteLine ( countTriplets ( n , points ) ) ; } }
Concentration of juice after mixing n glasses in equal proportion | C # implementation of the approach ; Function to return the concentration of the resultant mixture ; Driver code
using System ; class GFG { static double mixtureConcentration ( int n , int [ ] p ) { double res = 0 ; for ( int i = 0 ; i < n ; i ++ ) res += p [ i ] ; res /= n ; return Math . Round ( res , 4 ) ; } static void Main ( ) { int [ ] arr = { 0 , 20 , 20 } ; int n = arr . Length ; Console . WriteLine ( mixtureConcentration ( n , arr ) ) ; } }
Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B | C # implementation of the approach ; Function that returns true if the num contains a and b digits only ; Modular Exponentiation ; Function to return the modular inverse of x modulo MOD ; Function to return the required count of numbers ; Generating factorials of all numbers ; Generating inverse of factorials modulo MOD of all numbers ; Keeping a as largest number ; Iterate over all possible values of s and if it is a valid S then proceed further ; Check for invalid cases in the equation ; Find answer using combinatorics ; Add this result to final answer ; Driver Code
using System ; class GFG { static long MAX = ( long ) ( 1E5 + 5 ) ; static long MOD = ( long ) ( 1E9 + 7 ) ; static bool check ( long num , long a , long b ) { while ( num > 0 ) { long rem = num % 10 ; num /= 10 ; if ( rem != a && rem != b ) return false ; } return true ; } static long power ( long x , long y ) { long ans = 1 ; while ( y > 0 ) { if ( ( y & 1 ) > 0 ) ans = ( ans * x ) % MOD ; y >>= 1 ; x = ( x * x ) % MOD ; } return ans % MOD ; } static long modInverse ( long x ) { return power ( x , MOD - 2 ) ; } static long countNumbers ( long n , long a , long b ) { long [ ] fact = new long [ MAX ] ; long [ ] inv = new long [ MAX ] ; long ans = 0 ; fact [ 0 ] = 1 ; for ( long i = 1 ; i < MAX ; i ++ ) { fact [ i ] = ( 1 * fact [ i - 1 ] * i ) ; fact [ i ] %= MOD ; } inv [ MAX - 1 ] = modInverse ( fact [ MAX - 1 ] ) ; for ( long i = MAX - 2 ; i >= 0 ; i -- ) { inv [ i ] = ( inv [ i + 1 ] * ( i + 1 ) ) ; inv [ i ] %= MOD ; } if ( a < b ) { long x = a ; a = b ; b = x ; } for ( long s = n ; s <= 9 * n ; s ++ ) { if ( ! check ( s , a , b ) ) continue ; if ( s < n * b || ( s - n * b ) % ( a - b ) != 0 ) continue ; long numDig = ( s - n * b ) / ( a - b ) ; if ( numDig > n ) continue ; long curr = fact [ n ] ; curr = ( curr * inv [ numDig ] ) % MOD ; curr = ( curr * inv [ n - numDig ] ) % MOD ; ans = ( ans + curr ) % MOD ; } return ans ; } static void Main ( ) { long n = 3 , a = 1 , b = 3 ; Console . WriteLine ( countNumbers ( n , a , b ) ) ; } }
Number of elements with even factors in the given range | C # implementation of the above approach ; Function to count the perfect squares ; Driver code
using System ; class GFG { static int countOddSquares ( int n , int m ) { return ( int ) Math . Pow ( m , 0.5 ) - ( int ) Math . Pow ( n - 1 , 0.5 ) ; } static public void Main ( ) { int n = 5 , m = 100 ; Console . WriteLine ( " Count ▁ is ▁ " + ( ( m - n + 1 ) - countOddSquares ( n , m ) ) ) ; } }
Total position where king can reach on a chessboard in exactly M moves | C # implementation of above approach ; Function to return the number of squares that the king can reach in the given number of moves ; Calculate initial and final coordinates ; Since chessboard is of size 8 X8 so if any coordinate is less than 1 or greater than 8 make it 1 or 8. ; Calculate total positions ; Driver code
using System ; class GFG { static int Square ( int row , int column , int moves ) { int a = 0 , b = 0 , c = 0 , d = 0 , total = 0 ; a = row - moves ; b = row + moves ; c = column - moves ; d = column + moves ; if ( a < 1 ) a = 1 ; if ( c < 1 ) c = 1 ; if ( b > 8 ) b = 8 ; if ( d > 8 ) d = 8 ; total = ( b - a + 1 ) * ( d - c + 1 ) - 1 ; return total ; } public static void Main ( ) { int R = 4 , C = 5 , M = 2 ; Console . Write ( Square ( R , C , M ) ) ; } }
Find M | C # program to Find m - th number whose sum of digits of a number until sum becomes single digit is N ; Function to find the M - th number whosesum till one digit is N ; Driver Code
using System ; class GFG { static int findNumber ( int n , int m ) { int num = ( m - 1 ) * 9 + n ; return num ; } public static void Main ( ) { int n = 2 , m = 5 ; Console . Write ( findNumber ( n , m ) ) ; } }
Check if a number can be represented as a sum of 2 triangular numbers | C # implementation of the approach ; Function to check if it is possible or not ; Store all triangular numbers up to N in a Set ; Check if a pair exists ; Driver code
using System ; using System . Collections . Generic ; class GFG { static bool checkTriangularSumRepresentation ( int n ) { HashSet < int > tri = new HashSet < int > ( ) ; int i = 1 ; while ( true ) { int x = i * ( i + 1 ) / 2 ; if ( x >= n ) { break ; } tri . Add ( x ) ; i ++ ; } foreach ( int tm in tri ) { if ( tri . Contains ( n - tm ) ) { return true ; } } return false ; } public static void Main ( String [ ] args ) { int n = 24 ; if ( checkTriangularSumRepresentation ( n ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }
Absolute difference between the first X and last X Digits of N | C # implementation of the approach ; Function to find the number of digits in the integer ; Function to find the absolute difference ; Store the last x digits in last ; Count the no . of digits in N ; Remove the digits except the first x ; Store the first x digits in first ; Return the absolute difference between the first and last ; Driver code
using System ; class GFG { static int digitsCount ( int n ) { int len = 0 ; while ( n > 0 ) { len ++ ; n /= 10 ; } return len ; } static int absoluteFirstLast ( int n , int x ) { int i = 0 , mod = 1 ; while ( i < x ) { mod *= 10 ; i ++ ; } int last = n % mod ; int len = digitsCount ( n ) ; while ( len != x ) { n /= 10 ; len -- ; } int first = n ; return Math . Abs ( first - last ) ; } public static void Main ( String [ ] args ) { int n = 21546 , x = 2 ; Console . Write ( absoluteFirstLast ( n , x ) ) ; } }
Generate minimum sum sequence of integers with even elements greater | C # implementation of above approach ; Function to print the required sequence ; arr will hold the sequence sum variable will store the sum of the sequence ; If sum of the sequence is odd ; Print the sequence ; Driver Code
using System ; class GFG { public static void make_sequence ( int N ) { int [ ] arr = new int [ N + 1 ] ; int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 1 ) arr [ i ] = 1 ; else arr [ i ] = 2 ; sum += arr [ i ] ; } if ( sum % 2 == 1 ) arr [ 2 ] = 3 ; for ( int i = 1 ; i <= N ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { int N = 9 ; make_sequence ( N ) ; } }
Count Odd and Even numbers in a range from L to R | C # implementation of the above approach ; Return the number of odd numbers in the range [ L , R ] ; if either R or L is odd ; Driver code
using System ; class GFG { static int countOdd ( int L , int R ) { int N = ( R - L ) / 2 ; if ( R % 2 != 0 L % 2 != 0 ) N ++ ; return N ; } public static void Main ( ) { int L = 3 , R = 7 ; int odds = countOdd ( L , R ) ; int evens = ( R - L + 1 ) - odds ; Console . WriteLine ( " Count ▁ of ▁ odd ▁ numbers ▁ is ▁ " + odds ) ; Console . WriteLine ( " Count ▁ of ▁ even ▁ numbers ▁ is ▁ " + evens ) ; } }
Cost of painting n * m grid | C # implementation of the approach ; Function to return the minimum cost ; Driver code
using System ; class GFG { static int getMinCost ( int n , int m ) { int cost = ( n - 1 ) * m + ( m - 1 ) * n ; return cost ; } public static void Main ( ) { int n = 4 , m = 5 ; Console . WriteLine ( getMinCost ( n , m ) ) ; } }
Minimum operations required to make all the array elements equal | C # implementation of the above approach ; Function to return the minimum number of given operation required to make all the array elements equal ; Check if all the elements from kth index to last are equal ; Finding the 1 st element which is not equal to the kth element ; Driver code
using System ; class GFG { static void minOperation ( int n , int k , int [ ] a ) { for ( int i = k ; i < n ; i ++ ) { if ( a [ i ] != a [ k - 1 ] ) Console . WriteLine ( - 1 ) ; } for ( int i = k - 2 ; i > - 1 ; i -- ) { if ( a [ i ] != a [ k - 1 ] ) Console . WriteLine ( i + 1 ) ; } } static public void Main ( ) { int n = 5 ; int k = 3 ; int [ ] a = { 2 , 1 , 1 , 1 , 1 } ; minOperation ( n , k , a ) ; } }
Number of Simple Graph with N Vertices and M Edges | C # implementation of the approach ; Function to return the value of Binomial Coefficient C ( n , k ) ; Since C ( n , k ) = C ( n , n - k ) ; Calculate the value of [ n * ( n - 1 ) * -- - * ( n - k + 1 ) ] / [ k * ( k - 1 ) * ... * 1 ] ; Driver Code
using System ; class GFG { static int binomialCoeff ( int n , int k ) { if ( k > n ) return 0 ; int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } public static void Main ( ) { int N = 5 , M = 1 ; int P = ( N * ( N - 1 ) ) / 2 ; Console . Write ( binomialCoeff ( P , M ) ) ; } }
Increasing sequence with given GCD | C # implementation of the approach ; Function to print the required sequence ; Driver Code
using System ; class GFG { static void generateSequence ( int n , int g ) { for ( int i = 1 ; i <= n ; i ++ ) Console . Write ( i * g + " ▁ " ) ; } public static void Main ( ) { int n = 6 , g = 5 ; generateSequence ( n , g ) ; } }
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
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 ) ) ; } }
Check whether XOR of all numbers in a given range is even or odd | C # program to check if XOR of all numbers in range [ L , R ] is Even or odd ; Function to check if XOR of all numbers in range [ L , R ] is Even or Odd ; Count odd Numbers in range [ L , R ] ; Check if count of odd Numbers is even or odd ; Driver Code
using System ; class GFG { static string isEvenOrOdd ( int L , int R ) { int oddCount = ( R - L ) / 2 ; if ( R % 2 == 1 L % 2 == 1 ) oddCount ++ ; if ( oddCount % 2 == 0 ) return " Even " ; else return " Odd " ; } public static void Main ( ) { int L = 5 , R = 15 ; Console . WriteLine ( isEvenOrOdd ( L , R ) ) ; } }
Count number of trailing zeros in ( 1 ^ 1 ) * ( 2 ^ 2 ) * ( 3 ^ 3 ) * ( 4 ^ 4 ) * . . | C # implementation of the above approach ; Function to return the number of trailing zeros ; To store the number of 2 s and 5 s ; If we get a factor 2 then we have i number of 2 s because the power of the number is raised to i ; If we get a factor 5 then we have i number of 5 s because the power of the number is raised to i ; Take the minimum of them ; Driver code
using System ; class GFG { static int trailing_zeros ( int N ) { int count_of_two = 0 , count_of_five = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { int val = i ; while ( val % 2 == 0 && val > 0 ) { val /= 2 ; count_of_two += i ; } while ( val % 5 == 0 && val > 0 ) { val /= 5 ; count_of_five += i ; } } int ans = Math . Min ( count_of_two , count_of_five ) ; return ans ; } public static void Main ( ) { int N = 12 ; Console . WriteLine ( trailing_zeros ( N ) ) ; } }
Print numbers such that no two consecutive numbers are co | C # implementation of the approach ; Function to generate Sieve of Eratosthenes ; If prime [ p ] is not changed , then it is a prime ; Add the prime numbers to the array b ; Function to return the gcd of a and b ; Function to print the required sequence of integers ; Including the primes in a series of primes which will be later multiplied ; This is done to mark a product as existing ; Maximum number of primes that we consider ; For different interval ; For different starting index of jump ; For storing the numbers ; Checking for occurrence of a product . Also checking for the same prime occurring consecutively ; Including the primes in a series of primes which will be later multiplied ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static int limit = 1000000000 ; static int MAX_PRIME = 2000000 ; static int MAX = 1000000 ; static int I_MAX = 50000 ; static Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; static int [ ] b = new int [ MAX ] ; static int [ ] p = new int [ MAX ] ; static int j = 0 ; static bool [ ] prime = new bool [ MAX_PRIME + 1 ] ; static void SieveOfEratosthenes ( int n ) { for ( int i = 0 ; i < MAX_PRIME + 1 ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) { b [ j ++ ] = p ; } } } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void printSeries ( int n ) { SieveOfEratosthenes ( MAX_PRIME ) ; int i , g , k , l , m , d ; int [ ] ar = new int [ I_MAX + 2 ] ; for ( i = 0 ; i < j ; i ++ ) { if ( ( b [ i ] * b [ i + 1 ] ) > limit ) break ; p [ i ] = b [ i ] ; mp . Add ( b [ i ] * b [ i + 1 ] , 1 ) ; } d = 550 ; bool flag = false ; for ( k = 2 ; ( k < d - 1 ) && ! flag ; k ++ ) { for ( m = 2 ; ( m < d ) && ! flag ; m ++ ) { for ( l = m + k ; l < d ; l += k ) { if ( ( ( b [ l ] * b [ l + k ] ) < limit ) && mp . ContainsKey ( b [ l ] * b [ l + k ] ) && mp . ContainsKey ( p [ i - 1 ] * b [ l ] ) && ( l + k ) < d && p [ i - 1 ] != b [ l + k ] && p [ i - 1 ] != b [ l ] && mp [ b [ l ] * b [ l + k ] ] != 1 ) { if ( mp [ p [ i - 1 ] * b [ l ] ] != 1 ) { p [ i ] = b [ l ] ; mp . Add ( p [ i - 1 ] * b [ l ] , 1 ) ; i ++ ; } } if ( i >= I_MAX ) { flag = true ; break ; } } } } for ( i = 0 ; i < n ; i ++ ) ar [ i ] = p [ i ] * p [ i + 1 ] ; for ( i = 0 ; i < n - 1 ; i ++ ) Console . Write ( ar [ i ] + " ▁ " ) ; g = gcd ( ar [ n - 1 ] , ar [ n - 2 ] ) ; Console . Write ( g * 2 ) ; } public static void Main ( String [ ] args ) { int n = 4 ; printSeries ( n ) ; } }
Print numbers such that no two consecutive numbers are co | C # implementation of the approach ; Function for Sieve of Eratosthenes ; Function to print the required sequence ; Store only the required primes ; Base condition ; First integer in the list ; Second integer in the list ; Third integer in the list ; Generate ( N - 1 ) th term ; Generate Nth term ; Modify first term ; Print the sequence ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int MAX = 620000 ; static int [ ] prime = new int [ MAX ] ; static void Sieve ( ) { for ( int i = 2 ; i < MAX ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = 2 * i ; j < MAX ; j += i ) { prime [ j ] = 1 ; } } } } static void printSequence ( int n ) { Sieve ( ) ; List < int > v = new List < int > ( ) ; List < int > u = new List < int > ( ) ; for ( int i = 13 ; i < MAX ; i ++ ) { if ( prime [ i ] == 0 ) { v . Add ( i ) ; } } if ( n == 3 ) { Console . Write ( 6 + " ▁ " + 10 + " ▁ " + 15 ) ; return ; } int k ; for ( k = 0 ; k < n - 2 ; k ++ ) { if ( k % 3 == 0 ) { u . Add ( v [ k ] * 6 ) ; } else if ( k % 3 == 1 ) { u . Add ( v [ k ] * 15 ) ; } else { u . Add ( v [ k ] * 10 ) ; } } k -- ; u . Add ( v [ k ] * 7 ) ; u . Add ( 7 * 11 ) ; u [ 0 ] = u [ 0 ] * 11 ; for ( int i = 0 ; i < u . Count ; i ++ ) { Console . Write ( u [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int n = 4 ; printSequence ( n ) ; } }