LabVIEW Digest Programming Challenges

cancel
Showing results for 
Search instead for 
Did you mean: 

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
0 Kudos
Message 11 of 15
(3,446 Views)

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 problemWinning 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.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 oneThanks 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 oneThanks to CJWalker for this one

Message 12 of 15
(3,377 Views)

Not relevant. Please skip

0 Kudos
Message 13 of 15
(3,087 Views)

@chandrahasd23 wrote:

Simplest way to find the factorial of a number


  • This thread is about the reverse function, so your code is offtopic. Besides, we already have that function.
  • 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:

 

SimpleFactorial

 

 

 

 

Message 14 of 15
(3,081 Views)

This is my solution.

HOB Consultores S.A.
Área de Investigación, Desarrollo e Innovación Tecnológica
Download All
0 Kudos
Message 15 of 15
(2,799 Views)