How to resolve the algorithm N-smooth numbers step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm N-smooth numbers step by step in the Quackery programming language

Table of Contents

Problem Statement

n-smooth   numbers are positive integers which have no prime factors > n. The   n   in the expression   n-smooth   is always prime; there are   no   9-smooth numbers. 1   (unity)   is always included in n-smooth numbers.

2-smooth   numbers are non-negative powers of two. 5-smooth   numbers are also called   Hamming numbers. 7-smooth   numbers are also called   humble numbers.

A way to express   11-smooth   numbers is:

All ranges   (for   n)   are to be inclusive, and only prime numbers are to be used. The (optional) n-smooth numbers for the third range are:   503,   509,   and   521. Show all n-smooth numbers for any particular   n   in a horizontal list. Show all output here on this page.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm N-smooth numbers step by step in the Quackery programming language

Source code in the quackery programming language

  [ behead 0 swap rot
    witheach 
      [ 2dup < iff
          drop done
        nip nip 
        i^ 1+ swap ] ]               is smallest   ( [ --> n n )

  [ stack ]                          is end.test   (   --> s   )

  [ ]'[ end.test put
    dup temp put
    ' [ 1 ]
    0 rot size of
    [ over end.test share do if done
      [] unrot 
      dup dip
        [ witheach
            [ dip dup peek 
              temp share i^ peek *
              rot swap join swap ] ]
      rot smallest
      dip 
        [ 2dup peek 1+ unrot poke ]
      rot swap over
      -1 peek over = iff
        drop else join
      swap again ]
    drop
    end.test release
    temp release ]                   is smoothwith ( [ --> [   )
    
  [ ' [ 2 3 5 7 11 13 17 19 23 29 ] 
    swap split drop ]                is primes     ( n --> [   )
    
  10 times 
    [ i^ 1+ primes 
      smoothwith [ size 25 = ]
      echo cr ]
  cr
  9 times
    [ i^ 2 + primes
      smoothwith [ size 3002 = ]
      -3 split nip echo cr ]

  

You may also check:How to resolve the algorithm One of n lines in a file step by step in the Run BASIC programming language
You may also check:How to resolve the algorithm CSV to HTML translation step by step in the REXX programming language
You may also check:How to resolve the algorithm String length step by step in the Raku programming language
You may also check:How to resolve the algorithm Longest increasing subsequence step by step in the OCaml programming language
You may also check:How to resolve the algorithm Self-describing numbers step by step in the BBC BASIC programming language