Smallest and Largest Palindrome with N Digits | C # implementation of the approach ; Function to print the smallest and largest palindrome with N digits ; Driver Code
using System ; class GfG { static void printPalindrome ( int n ) { if ( n == 1 ) { Console . WriteLine ( " Smallest ▁ Palindrome : ▁ 0" ) ; Console . WriteLine ( " Largest ▁ Palindrome : ▁ 9" ) ; } else { Console . WriteLine ( " Smallest ▁ Palindrome : ▁ " + ( int ) ( Math . Pow ( 10 , n - 1 ) ) + 1 ) ; Console . WriteLine ( " Largest ▁ Palindrome : ▁ " + ( ( int ) ( Math . Pow ( 10 , n ) ) - 1 ) ) ; } } public static void Main ( String [ ] args ) { int n = 4 ; printPalindrome ( n ) ; } }