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 _06.Special_Numbers
- {
- class Special_Numbers
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- for (int num = 1; num <= n; num++)
- {
- int sumOfdigit = 0;
- int digit = num;
- while (digit > 0)
- {
- sumOfdigit += digit % 10;
- digit /= 10;
- }
- bool isSpecial = (sumOfdigit == 5 && (sumOfdigit % 5 == 0)) ||
- (sumOfdigit == 7 && (sumOfdigit % 7 == 0)) || (sumOfdigit == 11 && (sumOfdigit % 11 == 0));
- Console.WriteLine("{0} -> {1}", num, isSpecial);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement