# LabVIEW Digest Programming Challenges

This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.

## Re: LabVIEW Digest Challenge 2

Heres mine!

(Small edit: didn't handle zero before)

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 11 of 15
(724 Views)

## Re: LabVIEW Digest Challenge 2

Hi Everyone,

It looks like I might have done a competition that was a bit too easy this time around! We've had a lot of correct answers.

This challenge's winner is sankar06! I'm working on getting you your free certification exam now! Congratulations!

We'll be back with another challenge in the next few months so keep an eye out for the next LV Digest

Winning entry - nice use of an already inbuilt function and reversing the problem

Here are some of our other entries, all quite different from each other.

Highlight - nice checking that the number is positive with the case structure!

Thanks to James_McN for this one.

Another different example again, using some best programming practices here with the wait for ms function. Always good to make it a habit!

Thanks to Iarall for this one

This was the only VI I checked that properly accounted for the fact that the number 1 can be both 0! and 1!. Something I hadn't considered myself.

Thanks to CJWalker for this one

Message 12 of 15
(655 Views)

Message 13 of 15
(365 Views)

## Re: LabVIEW Digest Challenge 2

@chandrahasd23 wrote:

Simplest way to find the factorial of a number

• Since you only operate on I32, you'll quickly get wraparound and incorrect results, even negative results!
• The input is N and the output is Factorial(N), so don't name the input "factorial" and the output "Result", confusing the user.
• The indicator belongs after the FOR loop. There is absolutely no need to display intermediary values which have nothing to do with the result..
• The input needs to be an integer, it cannot be fractional. Change to the correct representation.
• There is a +1 primitive, no need for the diagram constant.

In summary, you code is not the "simplest way". It's not even the correct way!

To calculate a factorial, even is the result has tens of thousands of digits, have a look here:

LabVIEW Champion Do more with less code and in less time
Message 14 of 15
(359 Views)

## Re: LabVIEW Digest Challenge 2

This is my solution.

HOB Consultores S.A.
Área de Investigación, Desarrollo e Innovación Tecnológica
Message 15 of 15
(77 Views)
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.