найти числа во входном диапазоне, которые делятся поровну на 3. Можно использовать только операторы =, ++, -.
Я пытался получить остаток с помощью операторов сдвига и других циклов, но мне всегда требуется - = или что-то подобное.
Console.Clear();
int n,
d,
count = 1;
// get the ending number
n = getNumber();
// get the divisor
d = 3;// getDivisor();
Console.WriteLine();
Console.WriteLine(String.Format("Below are all the numbers that are evenly divisible by {0} from 1 up to {1}", d, n));
Console.WriteLine();
// loop through
while (count <= n)
{
// if no remainder then write number
if(count % d == 0)
Console.Write(string.Format("{0} ", count));
count++;
}
Console.WriteLine();
Console.WriteLine();
Console.Write("Press any key to try again. Press escape to cancel");
Ожидаемые результаты:
Enterконечное число: 15
Ниже приведены все числа, которые делятся поровну на 3 от 1 до 15
3, 6, 9, 12, 15