Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace test
- {
- class Program
- {
- static int Sum (int a)
- {
- int res = 0;
- for (int i = a; i > 0;) {
- res += i % 10;
- i = i / 10;
- }
- return res;
- }
- static void Main ()
- {
- Console.WriteLine ("Enter a & b ");
- int a = int.Parse (Console.ReadLine ());
- int b = int.Parse (Console.ReadLine ());
- Console.WriteLine ("Enter K ");
- int k = int.Parse (Console.ReadLine ());
- for (int i = a; i <= b; i++) {
- if ( Sum(i) == k)
- Console.WriteLine ("{0} ", i);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment