BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Fun Coding Challenges / Questions

I would give you Kudos Darren for a much simplier code (and faster running) then even I did, but yours is flawed. It doesn't handle numbers larger than an I32 which maxes out with a input of 23.

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 51 of 53
(2,294 Views)

Oops, I didn't realize the I32 was rolling over. Ok fine, here it is with the math VI inlined so everything can operate on I64.

 

Spoiler
lcm2.png
Message 52 of 53
(2,287 Views)

How about bonus points for three different approaches?  I haven't benchmarked them against each other or other solutions.

 

Spoiler
First approach builds an array containing all necessary prime factors, the second keeps a running multiple, and the third is a different way of building the array.

LCM.png
0 Kudos
Message 53 of 53
(2,255 Views)