Thread: Finding divisors

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by xbusterx View Post
    um like sum += num ?
    Right.

  2. #17
    Registered User
    Join Date
    Sep 2008
    Posts
    45
    Quote Originally Posted by tabstop View Post
    Right.
    Ya don't I don't know how to do that here since i is changing.

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by xbusterx View Post
    Ya don't I don't know how to do that here since i is changing.
    Since that's exactly what you want and need to happen, I fail to see how that's a problem.

    (Or is your task not to add, but to count? In that case you would always add 1, since that's how people count.)

  4. #19
    Registered User
    Join Date
    Sep 2008
    Posts
    45
    Quote Originally Posted by tabstop View Post
    Since that's exactly what you want and need to happen, I fail to see how that's a problem.

    (Or is your task not to add, but to count? In that case you would always add 1, since that's how people count.)

    Ok so can I do this?


    Code:
    int sum =0; 
    int n;
    
    cout << enter number;
    cin >> n; 
    
    for (int i = 1 ; i < n ; i++ )
    
    if ( n &#37; i = 0 )
        sum += i
    Last edited by xbusterx; 10-04-2008 at 08:07 PM.

  5. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You have to use == to compare numbers, but yes, that's what we've been waiting for.

  6. #21
    Registered User
    Join Date
    Sep 2008
    Posts
    45
    Quote Originally Posted by tabstop View Post
    You have to use == to compare numbers, but yes, that's what we've been waiting for.
    Code:
    int sum =0; 
    int n;
    
    cout << enter number;
    cin >> n; 
    
    for (int i = 1 ; i < n ; i++ )
    
    if ( n % i == 0 )
        sum += i

    better lol?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. tools for finding memory leaks
    By stanlvw in forum C++ Programming
    Replies: 4
    Last Post: 04-03-2009, 11:41 AM
  2. display of divisors
    By Lissa in forum C++ Programming
    Replies: 3
    Last Post: 10-19-2008, 11:20 AM
  3. Finding primes
    By starripper in forum C++ Programming
    Replies: 19
    Last Post: 01-14-2006, 04:17 PM
  4. Help with Computing Divisors
    By MrPink in forum C++ Programming
    Replies: 2
    Last Post: 09-30-2005, 07:35 PM
  5. MFC :: Finding Child Window of a CWnd* Object?
    By SyntaxBubble in forum Windows Programming
    Replies: 2
    Last Post: 09-06-2003, 09:06 AM