+ 1
Divisors
So a friend of mine proposed a challenge to find all divisors for each number from 1 to 100 I did this, but I want to exclude the number itself from the list of divisors. so for an example l, lets use 6 I want it to display 1, 2 and 3, but not 6. How can I do this? I've tried everything I can think of https://code.sololearn.com/crgVG3IEEMDI/?ref=app
7 Respostas
+ 5
I agree with the answer above.
2. Option:
When you think about divisors- what is the biggest divisor of any number (apart from itself)?
It's half of the number, right?
So you can also write your inner for loop like this:
for(int u=1; u<=i/2; u++)
+ 3
There are other ways, but this should work too: replace lines 9-15 by
if(u == i) {
cout << endl;
cout << endl; // >:)
}
else if(i%u == 0) {
cout << u << " ";
}
+ 3
Just put a line break in front of Number:
+ 2
So I implemented your solution dρlυѕρlυѕ
now the first iteration doesn't include a line break.
+ 2
dρlυѕρlυѕ welp that solution was simple and obvious. Lol. Thanks.
+ 2
Don't mention it. 👍