How to resolve the algorithm Count in factors step by step in the Run BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Count in factors step by step in the Run BASIC programming language

Table of Contents

Problem Statement

Write a program which counts up from   1,   displaying each number as the multiplication of its prime factors. For the purpose of this task,   1   (unity)   may be shown as itself.

2   is prime,   so it would be shown as itself.       6   is not prime;   it would be shown as

2 × 3

{\displaystyle 2\times 3}

. 2144   is not prime;   it would be shown as

2 × 2 × 2 × 2 × 2 × 67

{\displaystyle 2\times 2\times 2\times 2\times 2\times 67}

.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Count in factors step by step in the Run BASIC programming language

Source code in the run programming language

for i = 1000 to 1016
  print i;" = "; factorial$(i)
next
wait
function factorial$(num)
 if num = 1 then factorial$ = "1"
 fct = 2
 while fct <= num
 if (num mod fct) = 0 then
   factorial$ = factorial$ ; x$ ; fct
   x$  = " x "
   num = num / fct
  else
   fct = fct + 1
 end if
 wend
end function

  

You may also check:How to resolve the algorithm Power set step by step in the OPL programming language
You may also check:How to resolve the algorithm Continued fraction step by step in the Clojure programming language
You may also check:How to resolve the algorithm Sierpinski triangle step by step in the Burlesque programming language
You may also check:How to resolve the algorithm Fivenum step by step in the jq programming language
You may also check:How to resolve the algorithm Left factorials step by step in the Mathematica/Wolfram Language programming language