Jump to content

Talk:Semiprime

From Rosetta Code

task clarification

The use of the phrase natural numbers (according to Wikipedia)

(quoted from Wikipedia   Natural number:

There is no universal agreement about whether to include zero in the set of natural numbers: some define the natural numbers to be the positive integers {1, 2, 3, ...}, while for others the term designates the non-negative integers {0, 1, 2, 3, ...}. The former definition is the traditional one, with the latter definition having first appeared in the 19th century.


I personally like   positive integers   or   non-negative integers   for one or the other;   that way, there can be no misunderstanding. -- Gerard Schildberger (talk) 01:17, 21 February 2014 (UTC)

Of course, if all program examples would handle both cases, this would be a moot point. -- Gerard Schildberger (talk) 01:17, 21 February 2014 (UTC)

It doesn't matter when taken in this context. Zero is never taken as prime.
That was never my point. Unity also isn't a prime. But an isPrime function should be able to test any integer and return a correct result (as to being a prime or not) without giving an error or causing a loop. Same thing with an isSemiprime function. It should be able to return a correct result. Understanding that extremely large numbers would be problematic, of course. -- Gerard Schildberger (talk) 08:00, 21 February 2014 (UTC)
Are you saying that the task description is confusing as it stands? --Paddy3118 (talk) 07:17, 21 February 2014 (UTC)
Well, maybe not confusing, but it could be clarified. The use of any phrase (or word) that is under contention (disagreement) should never be used in a definition. If not, then we could say that semiprimes are the product of exactly two (possibly equal) primes. The use of a clarifying adjective should be definitive, and not be argumentative (since there is not an agreed-on definition). I like Mathworld's definition better: a semiprime, also called a 2-almost prime, biprime, or p q-number, is a composite number that is the product of two (possible equal) primes. This also has the advantage of introducing other (alias) names for people searching for alternate names. A note about the square of a prime being, by definition, is a semiprime would be a nice addition. -- Gerard Schildberger (talk) 08:00, 21 February 2014 (UTC)
I don't agree with "The use of any phrase (or word) that is under contention (disagreement) should never be used in a definition". Context and audience mean a lot. --Paddy3118 (talk) 09:04, 21 February 2014 (UTC)

a graphic view of the first 10k semi-primes

For those that are interested, here is the output of my   $CALC   (REXX) program that shows a binary map of the first 10k semiprimes.

The command used was:                       (extra blanks were used to make the command's arguments easier to read)

      $CALC  trans{ isSemiPrime[ iota(10k) ], 'fefa'x, 10}   ;;;  SQUISH  GRoup 100 

The   isSemiPrime   BIF outputs a   0   (zero) to indicate the number isn't semi-prime,   or a 1   (unity) to indicate a semi-prime.

The     translate       BIF converts (for easier perusing) ones and zeroes to   ■   and   ·     [the square bullets are the semi-primes].

The         iota            BIF generates the numbers   1 ──► 10,000   which are passed to the   isSemiPrime   BIF.

The      SQUISH         option removes all blanks from the output   (except for the index).

The      GROUP         option groups  100   output items per line.


(Output is shown at   2/3   size.)

                              ╔═══════════════════════════════════════════════╗
                              ║ trans{ isSemiPrime[ iota(10k) ], 'fefa'x, 10} ║
                              ╚═══════════════════════════════════════════════╝
    1► ···■·■··■■···■■·····■■··■■······■■■··■■······■··■·■···■·■■···■··■···■····■··■····■··■■■···■·■■■·····
  101► ·····■····■···■··■■·■■■·····■···■■······■■■·■■········■··■■·■····■··■·······■■····■·■·■······■······
  201► ■■■·■■··■···■■■·■■■·■····■········■·■·········■·■···■■····■··■··■·■······■···■········■·■·■···■··■■·
  301► ■■■·■···■····■····■·■·■··■■·■····■■···■·■····■········■··■··■■··■·····■·····■···■■···■····■·■■■··■··
  401► ··■···■···■·■·■·■····■····■·········■·······■■■···■·■■···■·······■··■·■·■····■··■■··■···■···■···■···
  501► ■■··■·····■··■■·■·■······■■·■···■·■·■■···■■·■·····■·■■····■··■··■■······■·····■·■·■··■··■·■·····■···
  601► ··········■··■·······■■··■··■···■■■·············■·····■······■····■·■·■··■····■·■···■·■·■····■■·■■■·
  701► ··■··■■·····■···■■··■·■·······■··■··■·······■■··■···■·■··■····■··■■···■······■■·■···■···■·■·■■····■·
  801► ·■■···■·····■·■·■■············■···■··■··■■■·····■·■··········■··■■··■·■······■■······■··■···■·■··■■·
  901► ■···■·······■■··■···■■■··■······■■····■···■·····■·■···■··■■·■···■·······■■····■··■··■···■···■·■··■··
 1001► ··■··■■···■······■········■·········■···■■■··■■·······■·■·■·······■·····■···■·■·■■···········■····■·
 1101► ■·········■··■■···■·■····■······■·■·■■■·■■··■·■·■····■··■·■·····■·■·■····■··■········■··■·■···■··■■·
 1201► ·■■·■·■···■··■····■······■■······■···■··■·■···■·····■·■·■···■■■···■···■·■········■··■■······■■····■·
 1301► ·····■······■·■·■■···■······■···■···■·■···■·■■■·■·■··■■·■·····■··■··■·■·······■··■■·■·■·■·■·■···■···
 1401► ■■■·■·····■···■·■■··················■■··■············■··■···■···■■··■···■···■■·······■··········■···
 1501► ■■····■·■···■■··■····■····■·■·····■·■■··■····■········■·····■·■·■···■····■··■·······■···■·■··■······
 1601► ··■··············■···■■·······■·■·····■·■■■··■··■·■··■■··■··■·········■·■····■■·■···■·■·■·■·········
 1701► ··■··■■···■·■■··■■·······■■···■···■···■·····■·····■··■··■···■■■·■■··■····■····■·■···········■·■·■·■·
 1801► ··■···■······■··■·■·■■······■·····■·■■■·■·■·····■·■·■···■■······■········■·······■■·······■·■■■·■···
 1901► ··■··■··■·····■···■·■·■···■·■····■··■·■·■■■·■········■··■·■·■·■··■■·■·······■···■■■·■·····■··■······
 2001► ····■············■■·■····■····■·■····■··■■··■·■·■·■·······■··■···■····■·■···■■················■··■··
 2101► ■■■·■···········■·■··■■··■■··········■········■·■·····■·■·■·····■·■···■·■■··■···■■■··■··■·■··■■···■·
 2201► ■····■··■·····■·■■■·······■·■·■··■··········■■··■···■···■■····■·······■·······■···■·■·····■·········
 2301► ·■··■■■·······■·■·■·■·■··■■·■·····■······■··········■·····■·■■■·····■····■···········■····■···■·····
 2401► ·■····■·····■·····■······■■·■···■■■·······■··■··■···■·■··■··■■■·····■·■··■····■·■·■···■·■·■···■·■■··
 2501► ■·····■·■···■·■·■■■·············■···■·······■········■···■■·■·■··■■·■·■·■···■■··■■····■·■····■····■·
 2601► ·■■·■■····■··■■·······■···■·■·■······■··■■■·····■·■·■■······■·······■···········■···················
 2701► ■···■···············■■■·········■■■·······■··■■·········■·■·■■········■·■·····■·····■·■··········■··
 2801► ······■·■·■·■·■··■····■···■···■·······■·■···■■·······■■··■■···■··■■·■········■··■···■·······■■····■·
 2901► ■■···■····■·■····■··■·■·····■·■·■·■·····■■····■·■·■·······■··■··■■······■■··■■··■·■··■■···■·■·■··■··
 3001► ····■·■·····■···■····■····■·■·■···■···■···■··■■·····■···■····■■·■·····■·■···■·······■■····■·■·■·■■■·
 3101► ■·■··■■·····■···■■········■···■·■■····■··■■···■·■·■·■·■··■··■····■······■·········■·····■···■■··■·■·
 3201► ·■··■·■······■■··■····■··■■·····■·■··■■·■■····■······■······■·■·■···■···■■··■·■·■·····■···■·■·■·····
 3301► ····■···■····■··■········■■······■··■■··■·······■·■·■···········■···■·······■·■···■·■■■······■··■■··
 3401► ■·■·····■·····■··■■·■·····■···■·····■·■··■■··■······■·■···■······■······■·······■■····■·■···■■··■···
 3501► ··■·■■······■····■··■·■···················■·■·····■··■······■·■··■··■····■···■■·······■·■·····■···■·
 3601► ■■■·······■··········■······■·····■···■·■····■■·■·■·■·······■■··■·■·■·········■···■···■·····■■■·····
 3701► ······■···■·■·■·····■■···········■··■····■■··■■·■····■■··■····■·············■■··■···■·■···■·······■·
 3801► ·■··■···■·■··■··■········■■·■·■·····■·■·■···■···■·········■··■··■■■·■···■·········■·······■·■····■■·
 3901► ■■■·····■···········■·············■·■···■····■··■···■···■■■·■·■·········■■··■·■·■·■·■■····■··■··■■··
 4001► ·····■··■············■········■·■■··■·■···■·■········■■··■··■·■·····■········■····■···■·········■···
 4101► ■·■·■■··■·····■·■·■·■····■········■··■··■·■·■·····■··········■■··■··■·■··■···■··■·■···■·■···■·■·■■··
 4201► ······■·····■········■■··■■·········■·········■·■········■···■··■·■·■····■····■·■■··■■■···■···■···■·
 4301► ··■··■■·■···■·■·■·■·■■········■·■·······■·■·······■·■····■■·······■·■·······■·■·■···■·■·····■·····■·
 4401► ····■■····■·■■■·■········■■·■·····■···■··■■·····■···■·······■·····■·■·■··■···■■······■■·■·······■·■·
 4501► ■■········■·················■·■·■■■·■■··■····■······■·■···■··■······■·■·■■··■·■······■··■···■■■·····
 4601► ■·····■·■···■····■■··■····■·■·■·■···········■·■···········■·■····■■·········■■··■■··■·■······■····■·
 4701► ■■··■···■·■·■■··■·········■·······■·■·■·■■····■·■····■··■····■■·■■··■·■·····■■··■····■····■······■··
 4801► ··■·······■·······■·■■····■·■····■■·■·■·■·■··■■·■···■·■·■·■···■···■·····■■······■■■·■·····■··■··■···
 4901► ······■···■···■··■········■······■····■······■·······■■·······■·······■·······■·■···■···■·······■···
 5001► ■····■■·········■·········■·■···■·······■■··■·······■···■····■■·■···■·■······■■······■··■·■·■·■·■■··
 5101► ·■··■·····■··■········■···■·■·■·····■···■·■·····■·····■··■··■·■·■···■···■···■····■■··■····■···■···■·
 5201► ■·····■·····■····■■·■·■··········■······■■··■···■·■···■·■·■···■··■■·■·······■·········■·····■■····■·
 5301► ····■·····■··■■·■■··■····■■·■·■·······■··■··■···■···■■··■·■·■·■··■■···■··■··■■····■··■··■········■··
 5401► ■·■·······■··■·······■···■··■···■·■··■········■·······■··■■·■■··■···■···■········■··■···■···■···■■··
 5501► ·····■··■···■·■·················■■····■·■·■·■···■····■······■·····■··········■■··■■·■·■······■··■·■·
 5601► ■■■··■··■·■·■·■·■·■·······■·■·■·■···■■······■·················■··■■···■··■··■········■············■·
 5701► ·■■···■·····■■······■■■·····■·■·······■·······■·····■·■··■■·■···■·■···■·■■··■···········■···■■····■·
 5801► ··■··■··■·····■··■··············■■··■·········■·····■■■·················■····■············■·■·····■·
 5901► ····■■··■·■··■··■·■·■····■······■·■·■■··■■····■···■·······■·■·■·■···■·■·····■·■···■·····■·■·■···■■■·
 6001► ■■··■···■···■···■·■··■■·······■·■····■··■····■··■·■·······■·····■·····■··■··■···■■··■·■··········■··
 6101► ··■···■·■·····■·■·■··■····■······■····■·····■·········■·■■■·■····■■·■········■■·■···■·■·■·■·■·······
 6201► ······■·■········■········■·····■····■■·■■■·■···■·········■·■·····■······■······■·■·····■·····■·■···
 6301► ············■·····■······■····■·■■···■■·■·····■·■············■········■··■··■····■■·■·■·····■·■·····
 6401► ■·■··■■···■···■··■····■·····■·■·■■··■·■··■■·■·········■·■■■···■···■···············■·■·■·····■···■·■·
 6501► ·■■·■■··■·■··■■··■····■···■·····■·■·■·■·■■··············■·■·······················■···■·■···■·■··■··
 6601► ·■··■···■·■·■■··■···■·■··■··■·■···■··■■·■····■··■········■···■■···■···■·····■·····■··■·······■··■···
 6701► ······■···■·····■■···■······■·■·······■··■■··■··■·■·■···■·········■·■···■····■···■····■·········■·■·
 6801► ■···■·■·■····■··■·■·■····■········■···■···■···■·············■···■■············■·■·····■·■·■·■····■··
 6901► ■···■·······■■·······■···■■···■·■■··■■··■·■·········■···················■·····■··■······■·····■··■■·
 7001► ··■·····■·······■····■■·······■·■■··■···■···■·····■·■■···■··■·■··■■···■·■····■··■■····■···■·■■··■·■·
 7101► ··········■·■■■·■■····■·······■·■·■·····■■■·■·■·■···■···■····■··■■■·■·■·······■·■·■··■········■·■·■·
 7201► ■············■··■·····■··■····■·■■■·····■····■··■·■···■·····■■··■···■·■·■■··■·■······■··■·■···■·····
 7301► ··■·······■·■····■■···■···■···········■·■■■··■·······■■·■···■·■···■·····■···■·■··■····■···■··■··■···
 7401► ■■■·■···■·····■··■■·■·■···■···■···■··■■·■···■·■·····■■········■·■■····■······■····■·········■·■·····
 7501► ■·······■···■·····■··■········■··■···■····■···········■··■····■·······■··············■······■■··■···
 7601► ■····■··■···■·■·■·■·······■·■·■·■···■····■···■■···■·■·■·····■·■··■····■·······■··············■··■···
 7701► ·■···■··■·■···■·····■····■··■·······■·■·····■·■···■··■·······■■·■···■·■·■····■■·■·■···■·······■···■·
 7801► ■·····■···■·■■····■··■····■···■··■■·■■·······■··■·■···■··■■·■■■·······■··············■····■··■■·■·■·
 7901► ··■·····■···■·■·····■············■····■·■···············■···■·····■·■·■·····■■■·■···■···■·■·····■·■·
 8001► ·■■·■■······■■······■·■··■■···■·■·■··■···■··■·■·■·■··■··■···■·■·■·■···■·····■·■···■···········■·■■··
 8101► ·■··■········■····■·■·······■·■·■·■·■·■·■·■··■··■···■···■■■·············■········■··■■■·■···■···■■··
 8201► ■·■···■·····■········■■···■···················■·■·■··■··■■■·■····■■··········■■·····■·············■·
 8301► ■····■··■····■■··■··■·····■···■·■·■···■·■···■·■···■··■··■·■·······■···■·■·········■·······■·······■·
 8401► ■■■···■·■·■·■···■····■···········■···■··■···········■···■■■··■··■·····■·■·····■··■■·■■··■·■···■·■·■·
 8501► ··■··■■·■·■······■■··■······■·■··········■··■■··■·■·■···■···■····■■···■······■■···■···■·····■■······
 8601► ··■·■·····■···■·■···■···········■···■·■···········■·■■··■·■·■···■········■···■····■·······■······■··
 8701► ····■···■·■··■··■········■■·······■·······■··■··■·■·······■·····■·■·····■···■···■■········■··■■·■···
 8801► ■·······■···■···■■·······················■■··■····■·····■·■···········■·■·····■·■■··■···■·■··■····■·
 8901► ·■■···■·■···■■■·■···■····■■·······■···■·····■·■·····■········■···■··········■···■·■··■··■·······■···
 9001► ··■·■········■··■·■···■··■····■·■■··■■·······■■·····■·■·■···········■·■·■···■·■···■·····■····■··■■··
 9101► ■·····■···■·■·■···■·■■■·······■··■········■···■·■·····■··········■■·■·········■··■■·········■■··■···
 9201► ■····■····■·····■·····■·····■···■·■·■····■····■·■···■·····■···■···■···■··■···■·······■■·■········■■·
 9301► ■■··■·■·····■■···········■■·■·····■··········■■·····■·■·■■····■·■·············■··■■·■···■·····■·····
 9401► ·····■■·■·■···············■··············■··■■··■·■······■·······■··■···········■·····■·■···■·······
 9501► ■■··■·■·■·······■■····■···■·■·····■·······■·········■···■···■·■·■■··■·■·■■··■■·······■··■···■····■■·
 9601► ·■····■·■·■·····■········■■······■··■···■·····■···■···■···■··■■·■·■···■·■·········■···■···■·········
 9701► ■·■···■·····■········■····■···■··········■··■·······■■■·■·■·■·■·······■·■···■■··············■···■·■·
 9801► ·····■··■···■····■········■··········■··■·····■·····■········■■·■■··■····■······■····■······■·■·■·■·
 9901► ·■■·········■■··■···■············■■·■■■···■··■······■···■·■·■···■···■····■··■·■···■·■■■·■·■·■·■·■■··
Cookies help us deliver our services. By using our services, you agree to our use of cookies.