How to resolve the algorithm Count in factors step by step in the 11l programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Count in factors step by step in the 11l 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 11l programming language
Source code in the 11l programming language
F get_prime_factors(=li)
I li == 1
R ‘1’
E
V res = ‘’
V f = 2
L
I li % f == 0
res ‘’= f
li /= f
I li == 1
L.break
res ‘’= ‘ x ’
E
f++
R res
L(x) 1..17
print(‘#4: #.’.format(x, get_prime_factors(x)))
print(‘2144: ’get_prime_factors(2144))
You may also check:How to resolve the algorithm Huffman coding step by step in the Go programming language
You may also check:How to resolve the algorithm Linear congruential generator step by step in the J programming language
You may also check:How to resolve the algorithm Temperature conversion step by step in the jq programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the DDNC programming language
You may also check:How to resolve the algorithm Currying step by step in the Python programming language