How to resolve the algorithm Brilliant numbers step by step in the Quackery programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Brilliant numbers step by step in the Quackery 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 Quackery programming language
Source code in the quackery programming language
[ 1 swap
[ 10 / dup iff
[ dip 1+ ]
else done
again ]
drop ] is digits ( n --> n )
[ over size 0 swap 2swap
bsearchwith < drop ] is search ( [ n --> n )
1010 eratosthenes
1 temp put
[] [] []
1010 times
[ i^ isprime if
[ temp share
i^ digits < if
[ nested join
[]
1 temp tally ]
i^ join ] ]
nested join
temp release
witheach
[ dup witheach
[ over witheach
[ over *
dip rot join unrot ]
drop behead drop ]
drop ]
sort
say "First 100 brilliant numbers:" cr
dup 100 split drop
unbuild
2 split nip -2 split drop
nest$ 40 wrap$ cr cr
6 times
[ dup dup 10 i^ 1+ **
say "First > "
dup 1 - echo
say " is "
search tuck peek echo
say " at position " 1+ echo
say "." cr ]
drop
You may also check:How to resolve the algorithm Additive primes step by step in the ARM Assembly programming language
You may also check:How to resolve the algorithm Bell numbers step by step in the Python programming language
You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the Delphi programming language
You may also check:How to resolve the algorithm Factorial step by step in the AsciiDots programming language
You may also check:How to resolve the algorithm Tau function step by step in the Factor programming language