The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(49G) Prime Counting Programme
08-02-2015, 08:55 AM (This post was last modified: 06-15-2017 01:41 PM by Gene.)
Post: #1
(49G) Prime Counting Programme
For integer input the programme returns the number of prime numbers up to & including the input.

eg For input

5

the programme returns

3.

Maximum input is 1680, higher values produce an error.

Code:

::
  CK1&Dispatch
  BINT1
  ::
    ::
      %ABS
      COERCEDUP
      BINT2
      #<case
      DROPZERO
      DUP
      BINT4
      #<case
      #1-
      DUP
      # 690
      #>
      caseSIZEERR
      '
      ::
        BINT1
        #=casedrop
        ::
          #1+
          #2/
        ;
        2DUP
        #1-
        2GETEVAL
        ROT
        1GETLAM
        4PICK
        NTHCOMPDROP
        #/
        SWAPDROP
        ROT
        #1-
        2GETEVAL
        #-
      ;
      {
        BINT2
        BINT3
        BINT5
        BINT7
        BINT11
        BINT13
        2REAL
        BINT19
        BINT23
        BINT29
        BINT31
        BINT37
        BINT41
      }
      FPTR2 ^2LAMBIND
      DUP
      UNCOERCE
      %SQRT
      %IP
      COERCE
      1GETLAM
      SWAP'
      #>
      POSCOMP
      #1-DUP
      #1-UNROT
      2GETEVAL
      ABND
      #+
    ;
    UNCOERCE
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(49G) Prime Counting Programme - Gerald H - 08-02-2015 08:55 AM



User(s) browsing this thread: 1 Guest(s)