Author Topic: Re: prime numbers searcher  (Read 2296 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: prime numbers searcher
« Reply #30 on: August 27, 2019, 12:34:28 am »
Isn’t the finding of superprimes as simple as storing the primes in an array, and then just referencing that array with the contents of the array?


An array of primes (start at P(1) if you don’t consider 1 a prime.)
P(0) = 1
P(1) = 2
P(2) = 3
P(3) = 5
P(4) = 7
P(5) = 11

And the superprimes:
P(P(0)) = 2
P(P(1)) = 3
P(P(2)) = 5
P(P(3)) = 11

Once you have your array (as I generated earlier), just reference it’s index with itself to see your super primes.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: prime numbers searcher
« Reply #31 on: August 27, 2019, 04:11:35 am »
Hi Steve I can agree

Quote
Posted by: TempodiBasic
« on: August 19, 2019, 07:49:36 PM
Thinking that the work of search primes is done by Steve and Ron77 and you Bplus
I simply can use the calculated list of prime numbers to work on it and find SuperPrime numbers.
;)
In this case it is just a selection of a list on itself using as index the single prime number in sequence.

Yep, not so difficult.

I'm posting again because I've on going about the translation of an algorithm found as exercise, to see how is under dust my C/C++ of time of DOS.
So I have learnt more about Ubound and Lbound and how to get the total of elements in an array ....
(thanks for tip in the other thread).
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: prime numbers searcher
« Reply #32 on: August 27, 2019, 09:31:01 am »
Isn’t the finding of superprimes as simple as storing the primes in an array, and then just referencing that array with the contents of the array?


An array of primes (start at P(1) if you don’t consider 1 a prime.)
P(0) = 1
P(1) = 2
P(2) = 3
P(3) = 5
P(4) = 7
P(5) = 11

And the superprimes:
P(P(0)) = 2
P(P(1)) = 3
P(P(2)) = 5
P(P(3)) = 11

Once you have your array (as I generated earlier), just reference it’s index with itself to see your super primes.

Ha yeah, and we did this a page or so ago! But TempodiBasic has some sort of C++ code that he insists on translating ;)