Results 1 to 1 of 1

Thread: PQ - List Prime

  1. #1
    Sir Moderator sandy666's Avatar
    Join Date
    May 2018
    Posts
    233
    Rep Power
    6

    Cool PQ - List Prime

    In mathematics, a prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In other words, a prime number is a number that cannot be formed by multiplying two smaller natural numbers.
    For example, the first few prime numbers are 2, 3, 5, 7, 11, 13, and so on. These numbers are divisible only by 1 and themselves.
    Prime numbers are of great importance in number theory and have various applications in cryptography, computer science, and other fields. They form the building blocks for the integers and play a fundamental role in many mathematical proofs and algorithms.

    ListPrime
    2
    3
    5
    7
    11
    13
    17
    19
    23
    29
    31
    37
    41
    43
    47
    53
    59
    61
    67
    71
    73
    79
    83
    89
    97
    101
    103
    107
    109
    and so on...

    Code:
    // fxSieveGenerate
    let
         Source = (pStart as number, pLimit as number) as list =>
             let
                xList = List.Generate(() => pStart * 2 , each _ < pLimit, each _ + pStart)
             in
                xList
    in
         Source
    Code:
    // ListPrime
    let
         PrimeLimit = 10000,
         SieveLimit = Number.Sqrt(PrimeLimit),
         Source = fxSieveGenerate(1, PrimeLimit),
         SieveNumbers = (parameter as record) as record =>
            let
              Iterator = parameter[pIterator] + 1,
              Sieve = fxSieveGenerate(parameter[pPrimes]{Iterator},PrimeLimit),
              NewPrimes = List.RemoveMatchingItems(parameter[pPrimes],Sieve),
              AllPrimes =
              if NewPrimes{Iterator+1} <= SieveLimit then
                  @SieveNumbers([pPrimes=NewPrimes,pIterator=Iterator])
                  else
                  [pPrimes=NewPrimes,pIterator=Iterator]
            in
              AllPrimes,
         PrimeList = SieveNumbers([pPrimes=Source,pIterator=-1])
    in
         PrimeList[pPrimes]
    Last edited by sandy666; 07-12-2023 at 04:20 AM.
    sandy
    I know you know but I forgot my Crystal Ball and don't know what you know also I may not remember what I did weeks, months or years ago so answer asap. Thinking doesn't hurt

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2023, 04:01 AM
  2. Replies: 2
    Last Post: 09-03-2013, 11:00 PM
  3. Replies: 2
    Last Post: 07-28-2013, 09:29 AM
  4. Replies: 4
    Last Post: 07-27-2013, 01:34 PM
  5. Delete List Contain Matching from Second List
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 12
    Last Post: 10-07-2012, 07:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •