Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
LabVIEW Zone LabVIEW Tools Network Resources LabVIEW Champions Student Corner User Groups Discussion Forum Code Sharing Learning Center

Coding Challenge - Factorial Coding Challenge

 Challenge Description:

 Factorial Coding Challenge

 Create a VI that computes the factorial of an I32 integer.

The factorial of an integer n, denoted as n!, is the product of all the positive integers from 1 to n. For example:

1! = 1
2! = 1 × 2 = 2
3! = 1 × 2 × 3 = 6
4! = 1 × 2 × 3 × 4 = 24

Additionally, the factorial of 0, 0!, is 1. For more information on the definition of factorials, visit the National Institute of Standards and Technology Web site.

Your VI will take, as input, an I32 integer between 0 and 10,000. It will output the factorial of that integer as a string. The resulting string must be the exact decimal representation of the factorial, correct to the last digit (no rounding and no leading zeroes, spaces). If the input value is out of range, your VI should return the message "ERROR: Input out of range" and terminate execution. Submissions yielding incorrect results will be disqualified.

The scoring will be done on several different operating systems and processor architectures. Scores will be based on accuracy and speed of the VI and the coding style. For help with coding style, see Chapter 6 of the LabVIEW Development Guidelines.

It should be simple to develop a VI which finds the factorial of smaller integers. The situation becomes more complex, however, when your output value is greater than what can be stored by an I32. That is why the output is stored as a string.

Your solution must use the same connector pane as Factorial.vi (download here). This is the framework for your VI. If you submit a solution with sub-VIs, please include all your VIs inside an LLB with the top-level VI named "Factorial.vi".

Download VI to get started.

Rules Specific to this Challenge

  1. All coding must be done in LabVIEW.
  2. No external code, DLLs, CINs, exes, etc
  3. Each factorial must be calculated from scratch. You may not use any lookup table of pre-computed factorials (except maybe for 0!) or caching of results from earlier runs.
  4. Have fun! Discuss this challenge on the Discussion Forums

  Discussion

 Other Info

 Ask questions and share ideas on this challenge in the Discussion Forums.   Suggest a Challenge

  See the results of Past Coding Challenges