flat assembler
Message board for the users of flat assembler.
Index
> Main > Tests for Primality |
Author |
|
Tyler 28 Mar 2010, 11:55
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? |
|||
28 Mar 2010, 11:55 |
|
baldr 28 Mar 2010, 13:55
Tyler,
No matter how're you coding, it's the algorithm that counts. Small Fermat theorem is handy. |
|||
28 Mar 2010, 13:55 |
|
LocoDelAssembly 28 Mar 2010, 14:48
When someone found "Primo" please post at least the search query text because I'm continuously unable to find it
|
|||
28 Mar 2010, 14:48 |
|
revolution 28 Mar 2010, 14:55
|
|||
28 Mar 2010, 14:55 |
|
revolution 28 Mar 2010, 14:57
Found with "q=Primo+primality+proving+program".
|
|||
28 Mar 2010, 14:57 |
|
LocoDelAssembly 28 Mar 2010, 17:13
Yep, it is much more reachable now, thanks
|
|||
28 Mar 2010, 17:13 |
|
Tyler 31 Mar 2010, 00:46
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? |
|||
31 Mar 2010, 00:46 |
|
revolution 31 Mar 2010, 01:16
Tyler wrote: Is that way acceptable? |
|||
31 Mar 2010, 01:16 |
|
Tyler 31 Mar 2010, 03:44
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. If I was going to deal with numbers bigger than could be natively(by the language), I'd probably made some asm routines to be called from the C/C++ since asm's better at addressing memory directly.(without being limited by types) 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. |
|||
31 Mar 2010, 03:44 |
|
nop 01 Apr 2010, 02:11
Tyler wrote: I would guess it would be quite a bit. quite a few bytes in fact |
|||
01 Apr 2010, 02:11 |
|
Tyler 01 Apr 2010, 06:20
Oh, you're funny!
There needs to be a sarcasm emoticon |
|||
01 Apr 2010, 06:20 |
|
Tyler 28 Jul 2010, 03:06
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.
|
|||
28 Jul 2010, 03:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.