flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tyler
If it matters, I'm actually coding in c++ for this one, but the ? applies to the method, not the code.
Is there a "pretty" way to test for primality or is it actually necessary to do something like this? I can think of plenty of ways to do it(ifs with mods was my first idea), but is there a purely methodical/mathematical way to know a # is prime? |
|||
![]() |
|
baldr
Tyler,
No matter how're you coding, it's the algorithm that counts. Small Fermat theorem is handy. |
|||
![]() |
|
LocoDelAssembly
When someone found "Primo" please post at least the search query text because I'm continuously unable to find it
![]() |
|||
![]() |
|
revolution
|
|||
![]() |
|
revolution
Found with "q=Primo+primality+proving+program".
|
|||
![]() |
|
LocoDelAssembly
Yep, it is much more reachable now, thanks
![]() |
|||
![]() |
|
Tyler
Sorry I didn't respond sooner, but I ended just making a linked list of all the primes I found, and since I was searching sequentially and starting at 2, all I had to do was test the next number against all the previous primes, and if none of them divided into the number being tested, it was prime.
Is that way acceptable? |
|||
![]() |
|
revolution
Tyler wrote: Is that way acceptable? |
|||
![]() |
|
Tyler
revolution wrote:
I doubt I'll encounter that problem, considering that I have no idea how to go about calculating numbers lager than a "double" in C/C++. I guess I could use something like http://sourceforge.net/projects/cpp-bigint/, but what good would that do me, since I don't understand it. ![]() Just a thought, imagine how much memory it would take to store all those primes leading up to the first hundred digit prime if I were to attempt to use said method on such a number. I would guess it would be quite a bit. |
|||
![]() |
|
nop
Tyler wrote: I would guess it would be quite a bit. quite a few bytes in fact ![]() |
|||
![]() |
|
Tyler
Oh, you're funny!
![]() ![]() There needs to be a sarcasm emoticon |
|||
![]() |
|
Tyler
http://cboard.cprogramming.com/general-discussions/128722-pluspluseureka.html - Read a couple of posts(It's not resolved in the first.). This could actually be useful.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.