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

This is a discussion on Find integer 1- 1000 w/ most divisors w/o remainder within the C++ Programming forums, part of the General Programming Boards category; Everyone, im kinda stuck on dis one problem. I have attempted it by nesting loops; however, i just can't get ...

  1. #1
    AlexDeToi
    Guest

    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

  2. #2
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    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

  3. #3
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    that was fast vVv

  4. #4
    AlexDeToi
    Guest
    Thanks for your help everyone, I really appreciate it

    Alex

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Find a certain bits in an integer array?
    By zyphirr in forum C Programming
    Replies: 1
    Last Post: 11-02-2008, 03:27 PM
  2. No Match For Operator+ ???????
    By Paul22000 in forum C++ Programming
    Replies: 24
    Last Post: 05-14-2008, 11:53 AM
  3. find the largest 1000 values
    By George2 in forum C Programming
    Replies: 5
    Last Post: 11-08-2007, 05:12 AM
  4. Won't Return pointer, i can't find why...
    By ss3x in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 08:50 PM
  5. Replies: 2
    Last Post: 01-26-2002, 07:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21