How to resolve the algorithm Harshad or Niven series step by step in the Craft Basic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Harshad or Niven series step by step in the Craft Basic programming language

Table of Contents

Problem Statement

The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits. For example,   42   is a Harshad number as   42   is divisible by   (4 + 2)   without remainder. Assume that the series is defined as the numbers in increasing order.

The task is to create a function/method/procedure to generate successive members of the Harshad sequence. Use it to:

Show your output here.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Harshad or Niven series step by step in the Craft Basic programming language

Source code in the craft programming language

for i = 1 to 1002

	let t = i
	let s = 0

	do

		let s = s + t % 10
		let t = int(t / 10)

		wait

	loop t > 0

	if i % s = 0 and (c < 20 or i > 1000) then

		let c = c + 1
		print c, " : ", i

	endif

next i


  

You may also check:How to resolve the algorithm Spiral matrix step by step in the NetRexx programming language
You may also check:How to resolve the algorithm Trigonometric functions step by step in the BQN programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the SETL programming language
You may also check:How to resolve the algorithm Retrieve and search chat history step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Quickselect algorithm step by step in the CLU programming language