PDA

View Full Version : Can someone help me?



nenzkypalisoc
August 14th, 2011, 03:31 AM
I want to create a program of getting the factors and it tells whether it is prime or composite.. for example

Type a positive integer: __
Factors are _ _ _ _ _ _
_ is composite

just like that when I run the program..

Thanks for those who are willing to help me. :)

schauerlich
August 14th, 2011, 03:34 AM
This sounds like homework, for starters. There are also tons and tons of code snippets on the web about this very topic.

cgroza
August 14th, 2011, 03:34 AM
In what language do you plan writing it in?
I recommend a very fast one, because this operation can take some time on large numbers.
I don't think there is much to program here, most of it consists of a math algorithm.

NovaAesa
August 14th, 2011, 12:12 PM
In what language do you plan writing it in?
I recommend a very fast one, because this operation can take some time on large numbers.
On a computer with standard von Neumann architecture this is indeed true, the best know integer factorization algorithms are exponential. I would still say it doesn't matter terribly much the speed of the language unless you are trying to squeeze performance out of the machine (in which case you would be better of just using one of the many well written libraries out there).

Of course, if/once quantum computers become mainstream, Shore's algorithm promises polynomial time :)

EDIT: also, do your own homework :P Or at least show what you have done so far and tell us what specific section you are having trouble with.

nenzkypalisoc
August 15th, 2011, 02:34 AM
Hmm. Let's say it's a case study. That it wasn't even explained what we really should do. It was just written on the board and we copied and we should submit it on saturday. I'm just hoping if someone could help me. We're using Turbo C++ Program and our topic that day he told us about our case study is about while, if n more.. blah blah..

Somebody help me please? :)
Thank You

lisati
August 15th, 2011, 07:13 AM
Friendly reminder from the forum code of conduct (http://ubuntuforums.org/index.php?page=policy):

While we are happy to serve as a resource for hints and for asking questions when you get stuck and need a little help, the Ubuntu Forums is not a homework service. Please do not post your homework assignments expecting someone else to do it for you. Any such threads will be taken offline and warnings or infractions may be issued.