Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Immutable;
- using System.Linq;
- namespace _10.TopNumber
- {
- class Program
- {
- public static bool SumDigits(string input)
- {
- if (input.Sum(x => Convert.ToInt32(x)) % 8 == 0)
- return true;
- else return false;
- }
- public static bool ContainsOdd(int input)
- {
- if (input % 2 != 0)
- return true;
- else return false;
- }
- public static void TopNum(string input)
- {
- for (int i = 1; i <= int.Parse(input); i++)
- {
- if (SumDigits(i.ToString()) == true && ContainsOdd(i) == true)
- {
- Console.WriteLine(i);
- }
- }
- }
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- TopNum(input);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement