How to resolve the algorithm Sequence of primes by trial division step by step in the AsciiDots programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sequence of primes by trial division step by step in the AsciiDots programming language

Table of Contents

Problem Statement

Generate a sequence of primes by means of trial division.

Trial division is an algorithm where a candidate number is tested for being a prime by trying to divide it by other numbers. You may use primes, or any numbers of your choosing, as long as the result is indeed a sequence of primes. The sequence may be bounded (i.e. up to some limit), unbounded, starting from the start (i.e. 2) or above some given value. Organize your function as you wish, in particular, it might resemble a filtering operation, or a sieving operation. If you want to use a ready-made is_prime function, use one from the Primality by trial division page (i.e., add yours there if it isn't there already).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Sequence of primes by trial division step by step in the AsciiDots programming language

Source code in the asciidots programming language

``warps
%$ABCPR

``outputs all primes up to and including the input
.-#?-A
B-P/$_#$_" "
R-*~
  \/

``primality test
   /---------------*-\
  //-----------{*}*~-+\
 ///--#1--\ /#1>/ \/ ||
 \\*/#2>*-\-~#0*>R   || 
/*>*+--++{%}/  \+>C  || ``signal to C triggers next number
|\--/>-/|       ||   || ``to be input from for loop
| /-~*--+-------^|   ||
| |[<]\ |       */   ||
| \-* | |       | /--+/
|/-[+]|[*]------+-<1#*
|\1#* \-+-------+----/
|   ~---*       ^--\
|   \---/       |  |
\------\        |  |
 /-----~\ /-----~#0/
P*#2{<}/\-*#2{=}/ ``hardcode <=1 and 2
 \---/    \---/

``for loop
``only outputs next number once C receives any input
.-\C#1-*--\ /--B
  # /-{+}-+-*--\ 
  1 | /---+----~
  *->-*\  \---\|
A{+}>*{-}*-{>}+/
   //|   \#0/ |
   \{*}-------/

  

You may also check:How to resolve the algorithm Fibonacci sequence step by step in the LLVM programming language
You may also check:How to resolve the algorithm Classes step by step in the MATLAB programming language
You may also check:How to resolve the algorithm Integer comparison step by step in the Sidef programming language
You may also check:How to resolve the algorithm Literals/String step by step in the V programming language
You may also check:How to resolve the algorithm RPG attributes generator step by step in the Delphi programming language