How to resolve the algorithm Brilliant numbers step by step in the Arturo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Brilliant numbers step by step in the Arturo programming language
Table of Contents
Problem Statement
Brilliant numbers are a subset of semiprime numbers. Specifically, they are numbers that are the product of exactly two prime numbers that both have the same number of digits when expressed in base 10. Brilliant numbers are useful in cryptography and when testing prime factoring algorithms.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Brilliant numbers step by step in the Arturo programming language
Source code in the arturo programming language
brilliant?: function [x][
pf: factors.prime x
and? -> 2 = size pf
-> equal? size digits first pf
size digits last pf
]
brilliants: new []
i: 2
while [100 > size brilliants][
if brilliant? i -> 'brilliants ++ i
i: i + 1
]
print "First 100 brilliant numbers:"
loop split.every: 10 brilliants 'row [
print map to [:string] row 'item -> pad item 4
]
print ""
i: 4
nth: 0
order: 1
while [order =< 6] [
if brilliant? i [
nth: nth + 1
if i >= 10^order [
print ["First brilliant number >= 10 ^" order "is" i "at position" nth]
order: order + 1
]
]
i: i + 1
]
You may also check:How to resolve the algorithm String matching step by step in the Picat programming language
You may also check:How to resolve the algorithm Substitution cipher step by step in the Haskell programming language
You may also check:How to resolve the algorithm Pythagorean quadruples step by step in the AWK programming language
You may also check:How to resolve the algorithm FASTA format step by step in the Objeck programming language
You may also check:How to resolve the algorithm Arrays step by step in the 6502 Assembly programming language