Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _25.MasterNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- for (int i = 1; i <= num; i++)
- {
- if (IsPalindrome(i.ToString())&& SumOfDigits(i) && HoldEvenDigits(i.ToString()))
- {
- Console.WriteLine(i);
- }
- }
- }
- static bool HoldEvenDigits(string num)
- {
- for (int i = 0; i < num.Length; i++)
- {
- if (num[i] % 2 == 0)
- {
- return true;
- }
- }
- return false;
- }
- static bool SumOfDigits(int n)
- {
- int sum = 0;
- while (n != 0)
- {
- sum += n % 10;
- n /= 10;
- }
- if (sum % 7==0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public static bool IsPalindrome(string value)
- {
- int min = 0;
- int max = value.Length - 1;
- while (true)
- {
- if (min > max)
- {
- return true;
- }
- char a = value[min];
- char b = value[max];
- if (char.ToLower(a) != char.ToLower(b))
- {
- return false;
- }
- min++;
- max--;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement