flat assembler
Message board for the users of flat assembler.
![]() |
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? |
|||
![]() |
|
baldr 28 Mar 2010, 13:55
Tyler,
No matter how're you coding, it's the algorithm that counts. Small Fermat theorem is handy. |
|||
![]() |
|
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
![]() |
|||
![]() |
|
revolution 28 Mar 2010, 14:55
|
|||
![]() |
|
revolution 28 Mar 2010, 14:57
Found with "q=Primo+primality+proving+program".
|
|||
![]() |
|
LocoDelAssembly 28 Mar 2010, 17:13
Yep, it is much more reachable now, thanks
![]() |
|||
![]() |
|
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? |
|||
![]() |
|
revolution 31 Mar 2010, 01:16
Tyler wrote: Is that way acceptable? |
|||
![]() |
|
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. ![]() 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 01 Apr 2010, 02:11
Tyler wrote: I would guess it would be quite a bit. quite a few bytes in fact ![]() |
|||
![]() |
|
Tyler 01 Apr 2010, 06:20
Oh, you're funny!
![]() ![]() There needs to be a sarcasm emoticon |
|||
![]() |
|
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.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.