How to resolve the algorithm Attractive numbers step by step in the EasyLang programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Attractive numbers step by step in the EasyLang programming language

Table of Contents

Problem Statement

A number is an   attractive number   if the number of its prime factors (whether distinct or not) is also prime.

The number   20,   whose prime decomposition is   2 × 2 × 5,   is an   attractive number   because the number of its prime factors   (3)   is also prime.

Show sequence items up to   120.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Attractive numbers step by step in the EasyLang programming language

Source code in the easylang programming language

func isprim num .
   if num < 2
      return 0
   .
   i = 2
   while i <= sqrt num
      if num mod i = 0
         return 0
      .
      i += 1
   .
   return 1
.
func count n .
   f = 2
   repeat
      if n mod f = 0
         cnt += 1
         n /= f
      else
         f += 1
      .
      until n = 1
   .
   return cnt
.
for i = 2 to 120
   n = count i
   if isprim n = 1
      write i & " "
   .
.

  

You may also check:How to resolve the algorithm Address of a variable step by step in the Axe programming language
You may also check:How to resolve the algorithm Count occurrences of a substring step by step in the Stata programming language
You may also check:How to resolve the algorithm Factors of a Mersenne number step by step in the Swift programming language
You may also check:How to resolve the algorithm Loops/For with a specified step step by step in the Ceylon programming language
You may also check:How to resolve the algorithm XML/XPath step by step in the LiveCode programming language