How to resolve the algorithm Sequence: smallest number with exactly n divisors step by step in the Action! programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sequence: smallest number with exactly n divisors step by step in the Action! programming language

Table of Contents

Problem Statement

Calculate the sequence where each term   an   is the smallest natural number that has exactly   n   divisors.

Show here, on this page, at least the first  15  terms of the sequence.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Sequence: smallest number with exactly n divisors step by step in the Action! programming language

Source code in the action! programming language

CARD FUNC CountDivisors(CARD a)
  CARD i,count

  i=1 count=0
  WHILE i*i<=a
  DO
    IF a MOD i=0 THEN
      IF i=a/i THEN
        count==+1
      ELSE
        count==+2
      FI
    FI
    i==+1
  OD
RETURN (count)

PROC Main()
  DEFINE MAX="15"
  CARD a,count
  BYTE i
  CARD ARRAY seq(MAX)

  FOR i=0 TO MAX-1
  DO
    seq(i)=0
  OD

  i=0 a=1
  WHILE i
  DO
    count=CountDivisors(a)
    IF count<=MAX AND seq(count-1)=0 THEN
      seq(count-1)=a
      i==+1
    FI
    a==+1
  OD

  FOR i=0 TO MAX-1
  DO
    IF i>0 THEN
      Print(", ")
    FI
    PrintC(seq(i))
  OD
RETURN

  

You may also check:How to resolve the algorithm Mayan numerals step by step in the Julia programming language
You may also check:How to resolve the algorithm Zumkeller numbers step by step in the Python programming language
You may also check:How to resolve the algorithm Repeat step by step in the Raku programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Free Pascal programming language
You may also check:How to resolve the algorithm Function definition step by step in the Factor programming language