Thread: Prime division

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    28

    Prime division

    Find out the number of prime numbers that divide a given number 'n' where 'n' lies within the range 1<=n<=10000 (note: 1 is not a prime)

    input:
    Total number of inputs
    n

    Output:
    The number of prime numbers that divide 'n'

    Sample Input:
    5
    7
    18
    2220
    7140
    2

    Sample Output:

    1
    2
    4
    5
    1

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    28
    i want to Find out the number of prime numbers that divide a given number 'n' where 'n' lies within the range 1<=n<=10000 (note: 1 is not a prime)

  4. #4
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    So, then find it out.
    Spidey out!

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Yes, you said that already.

    What have you written so far?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    28
    i want the algorithim of it?
    if you can then help me.
    thanks

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Find a prime number,
    work out whether it is a divisor of 'n' or not,
    repeat.

    OR
    Work out a divisor for 'n',
    check whether it is prime or not,
    repeat.

    What's so hard?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    I made a program that does this to an extent, too bad you haven't shown any code that we could help you with. Otherwise I could start pointing you in a certain direction.

    EDIT: ok I'll give some help. My algorithm uses Salem's first method.

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by scwizzo View Post
    EDIT: ok I'll give some help. My algorithm uses Salem's first method.
    Ha. You think, from the answers so far, this guy is actually going to bother finding out what Salem's first method is about? Or even to write a single line of code? He just wants teh codez.

  10. #10
    Registered User
    Join Date
    Jan 2009
    Posts
    28
    thanks

  11. #11
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by maifs View Post
    thanks
    You're very welcome. Byebye.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calculating prime factor of a huge number.
    By Bakster in forum C Programming
    Replies: 15
    Last Post: 02-20-2009, 12:06 PM
  2. prime number program with function
    By mackieinva in forum C Programming
    Replies: 17
    Last Post: 09-20-2007, 08:36 AM
  3. prime numbers, counters, help!
    By vege^ in forum C++ Programming
    Replies: 1
    Last Post: 03-10-2003, 04:32 PM
  4. Prime Wonder
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-07-2002, 11:49 PM
  5. Homework help
    By Jigsaw in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 05:56 PM