proc even(i:int):bool{.inline.}=imod2==0proc numStrength(i:int):int=## Calculate the strength of a number.#### A number's strength is determined by the number of times## it can divided in half until it reaches an odd number.vari=iwhilei.even:i=idiv2inc(result)proc strongestNum(n,m:int):int=## Given the closed interval [n, m], calculate the strongest number.vartopStrength=0foriinn..m:letstrength=numStrength(i)ifstrength>topStrength:topStrength=strengthresult=iassertstrongestNum(1,2)==2assertstrongestNum(5,10)==8assertstrongestNum(48,56)==48assertstrongestNum(129,193==192
There's definitely room to improve this, but I'm just starting to look into Nim's standard library, and I don't know all that's available to me yet.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here's a Nim submission!
There's definitely room to improve this, but I'm just starting to look into Nim's standard library, and I don't know all that's available to me yet.