How to resolve the algorithm Largest proper divisor of n step by step in the Lua programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Largest proper divisor of n step by step in the Lua programming language
Table of Contents
Problem Statement
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Largest proper divisor of n step by step in the Lua programming language
Source code in the lua programming language
for n = 1, 100 do -- show the largest proper divisors for n = 1..100
local largestProperDivisor, j = 1, math.floor( n / 2 )
while j >= 2 and largestProperDivisor == 1 do
if n % j == 0 then
largestProperDivisor = j
end
j = j - 1
end
io.write( string.format( "%3d", largestProperDivisor ) )
if n % 10 == 0 then io.write( "\n" ) end
end
You may also check:How to resolve the algorithm Anagrams step by step in the Oz programming language
You may also check:How to resolve the algorithm Substring step by step in the MUMPS programming language
You may also check:How to resolve the algorithm Show ASCII table step by step in the R programming language
You may also check:How to resolve the algorithm Extreme floating point values step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Sierpinski square curve step by step in the Julia programming language