LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Testing a number to see if it s prime WITHOUT using the Q&R function...Possible?

Solved!
Go to solution

How about using a Formula Node? 😛

========================
=== Engineer Ambiguously ===
========================
Message 11 of 20
(1,831 Views)

@altenbach wrote:
Maybe I should add this one to my benchmarks :o:D

OK, calculating the sum of all primes below 100M takes less than 1s for my fastest algorithm, while the regex version would take (extrapolated from the second order fit to the log-log plot) about ~212813680427 Weeks. I am not patiened enough to verify that. 😄 It is much slower than even the dumb algorithm.

(note that you need to increase the size of the upper initialzied array if you generate more polynomial terms).

Message 12 of 20
(1,819 Views)

@altenbach wrote:

[...] the regex version would take (extrapolated from the second order fit to the log-log plot) about ~212813680427 Weeks. I am not patiened enough to verify that. 😄 It is much slower than even the dumb algorithm.

Send me the program.  I have a really fast computer; it can complete an endless loop in under an hour.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 13 of 20
(1,804 Views)

@jcarmody wrote:

@altenbach wrote:

[...] the regex version would take (extrapolated from the second order fit to the log-log plot) about ~212813680427 Weeks. I am not patiened enough to verify that. 😄 It is much slower than even the dumb algorithm.

Send me the program.  I have a really fast computer; it can complete an endless loop in under an hour.


But you have to run in twice 🙂

 

Spoiler
Wasn't it Mr. Norris, who counted up to infinty... twice!
And he also caugth all pockemons ... with a wired phone
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 14 of 20
(1,791 Views)

I probably encourage the silliness but while we are at it the Expresion Node supports the "rem" operator see here ...

ExpresionNode.png...which is completely correct but totally useless.

 

Ben

 

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 15 of 20
(1,776 Views)

I made a thread specifically for these types of questions... I got insanely busy at work and haven't kept it up, but I love fun little challenges like this.  Feel free to contribute / post there 🙂

Message 16 of 20
(1,774 Views)

@jcarmody wrote:

Send me the program.  I have a really fast computer; it can complete an endless loop in under an hour.

Well, it would be trivial to only look at odd numbers (except for 2) for half the number of iterations, so your endless loop would complete in 30 minutes. 😄

0 Kudos
Message 17 of 20
(1,764 Views)

I was rading through the 2015 relesase notes when I found ...

 

Mathematics >>> Elementary & Special Functions >>> Discrete Math >>> Check Prime

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 18 of 20
(1,734 Views)

@Ben wrote:

I was rading through the 2015 relesase notes when I found ...

 

Mathematics >>> Elementary & Special Functions >>> Discrete Math >>> Check Prime

 


You can look at the code and it contains an awful amount of Q&Rs 😄

Trying to find the algorithm.. (there does not seem to be a help page).

0 Kudos
Message 19 of 20
(1,723 Views)

@altenbach wrote:

Trying to find the algorithm.. (there does not seem to be a help page).

Looks like the prime spiral sieve.

 

(A wheel factorization. The main advantage is that it uses very little memory and is pretty fast for that. Takes only about 2.5 hours to sum all primes below 100M. I am sure it can be improved, though)

Message 20 of 20
(1,719 Views)