Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace specialNumbers
- {
- class Program
- {
- static bool isPalindrome(int num)
- {
- string sNum = num.ToString();
- for (int i = 0; i < sNum.Length; i++)
- if (sNum[i] != sNum[sNum.Length - 1 - i]) return false;
- return true;
- }
- static bool SumOfDigits(int n)
- {
- int sum = 0;
- while (n > 0)
- {
- sum += n % 10;
- n = n / 10;
- }
- if (sum % 7 == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- static bool ContainsEvenDigit(int num)
- {
- string n = num.ToString();
- for (int i = 0; i < n.Length; i++)
- {
- if (n[i] % 2 == 0)
- {
- return true;
- }
- }
- return false;
- }
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- for (int i = 1; i <= n; i++)
- {
- if (isPalindrome(i) && SumOfDigits(i) && ContainsEvenDigit(i))
- {
- Console.WriteLine(i);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement