HP Forums
(49G) OEIS A018800: Smallest prime that begins with n - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (49G) OEIS A018800: Smallest prime that begins with n (/thread-9215.html)



(49G) OEIS A018800: Smallest prime that begins with n - Gerald H - 10-03-2017 09:39 AM

For natural number input N the programme returns the Nth element of the series

https://oeis.org/A018800

NB The sequence exhibits no gaps.

Size: 135.

CkSum: # 20661d

Code:
::
  CK1&Dispatch
  # FF
  ::
    DUP
    FPTR2 ^ISPRIME
    %0<>
    ?SEMI
    BINT7
    ONE_DO
    ZINT 10
    FPTR2 ^RMULText
    BINT10
    INDEX@
    FPTR2 ^RP#
    ONE_DO
    DUPINDEX@
    FPTR2 ^#>Z
    FPTR2 ^RADDext
    DUP
    FPTR2 ^ZPrime?
    ITE
    ::
      SWAPDROP
      ZEROZERO
      JSTOPSTO
      ExitAtLOOP
    ;
    ::
      DROP
      INDEX@
      BINT10
      #/
      DROP
      #3=
      case
      BINT4
      BINT2
    ;
    +LOOP
    LOOP
  ;
;