Thread: How the heck to I find factors in Programming? (Need some quick help)

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    38

    How the heck to I find factors in Programming? (Need some quick help)

    I gotta do a quick program that asks for all the factors of 2 poitive numbers (include 1 and itself), the prime factorization of each, the least common multiple (LCM) of the two integers, and the greatest common factor (GCF) of the two integers.

    The prime factorization stuff is whats giving me the problems.

    I hope someone can help. Its appreciated

    Thanks

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    155
    a factor is generally any integer that when divided into another integer has no remainder. That is the same as seeing if the modulo is zero. Therefore if(num % div == 0) div is a factor of num. Exactly what you mean by prime factorization is unclear, unless you mean all integer factors or only factors that are prime. That is, the prime factors of 8 could be 1, 2, 8 but not 4 since 4 is just 2 * 2 and therefore not prime.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    38

    Unhappy

    Ohh yea. I remember that stuff man. The problem is I dont know how to do that in a program. The only way I can think if doing it is by having the input number tested by every number individually. Is there a way to avoid that?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  2. Replies: 5
    Last Post: 04-16-2004, 01:29 AM
  3. Find all factors of a number
    By Spono in forum C Programming
    Replies: 5
    Last Post: 10-23-2003, 01:23 AM
  4. Quick Sort Help
    By NavyBlue in forum C Programming
    Replies: 1
    Last Post: 03-02-2003, 10:34 PM
  5. Replies: 0
    Last Post: 04-30-2002, 07:24 PM