I'm stuck with a problem.
I want to create program in C# which calculates entered numbers divisions, but I can not finish that program.
input | output |
---|---|
6 | 1, 2, 3, 6 |
7 | 1,7 |
8 | 1, 2, 4, 8 |
etc.
Here is my code:
namespace Divisions
{
class Program
{
static void Main(string[] args){
Console.WriteLine("Enter number:");
int input = Convert.ToInt32(Console.ReadLine());
int x = 1;
int y = input % x;
while(x<input){
x++;
while(y==0){
Console.WriteLine(x);
}
}
}
}
}
I tried every loop. I have changed this code more than 15 times. I used do while
loop, for loop
, even I tried to use while
and if
at the same time, but didn't work.