Find integer 1- 1000 w/ most divisors w/o remainder

• 03-24-2002
AlexDeToi
Find integer 1- 1000 w/ most divisors w/o remainder
Everyone, im kinda stuck on dis one problem. I have attempted it by nesting loops; however, i just can't get it mathematically. The problem is that i must make a program in C++ that finds the integer from 1 - 1000 with the most divsors tha produce no remainder. For example, the integer 60 has 12 divisors that produce no remainder. They are 1,2,3,4,5,6,10,12,15,20,30,60. Pleaze guys, i really need some help.

I had somethin like this

#include <iostream.h>

main()
{
long a,b,c;

for (a = 1; a <= 1000; a++)
{
for (b = 1; b <= 1000; b++)
{
c = a % b;

if (c == 0)
cout << a;
}
}

return 0;
}

Alex
• 03-24-2002
ihsir
use num to store the value of most divided w/o rem default 1

use a variable like count that increments +1 everytimes rem==0

use another variable like max which stores the value of prv# count and compares with count default =0

if max>count then num = value of the number in loop
• 03-24-2002
ihsir
that was fast vVv
• 03-24-2002
AlexDeToi
Thanks for your help everyone, I really appreciate it

Alex