How to resolve the algorithm Pernicious numbers step by step in the 11l programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pernicious numbers step by step in the 11l programming language
Table of Contents
Problem Statement
A pernicious number is a positive integer whose population count is a prime. The population count is the number of ones in the binary representation of a non-negative integer.
22 (which is 10110 in binary) has a population count of 3, which is prime, and therefore
22 is a pernicious number.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Pernicious numbers step by step in the 11l programming language
Source code in the 11l programming language
F is_prime(n)
I n < 2
R 0B
L(i) 2 .. Int(sqrt(n))
I n % i == 0
R 0B
R 1B
V i = 0
V cnt = 0
L
I is_prime(bits:popcount(i))
print(i, end' ‘ ’)
cnt++
I cnt == 25
L.break
i++
print()
L(i) 888888877..888888888
I is_prime(bits:popcount(i))
print(i, end' ‘ ’)
You may also check:How to resolve the algorithm Modular exponentiation step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Y combinator step by step in the Bracmat programming language
You may also check:How to resolve the algorithm Hash from two arrays step by step in the Ring programming language
You may also check:How to resolve the algorithm Digital root step by step in the Python programming language
You may also check:How to resolve the algorithm Word search step by step in the Nim programming language