04-24-2018 07:51 AM
Just looking at question 19 of the CLD-R exam 1. PLease can somebody tell me why the answer is c.24?
04-24-2018 08:07 AM
4*(3*(2*(1*1)))=24.
Also, if this was taken off the actual exam, you aren't supposed to share details of the questions.
04-24-2018 08:15 AM
The key part is the fact that this VI is reentrant. I admit it took me a minute to figure that part out as well. So the VI is calling itself with a decreasing value until the input is 0.
04-24-2018 08:18 AM
Don't worry, it's off the practice sample exam paper that NI provide.
So because it's reentrant it takes the input of 4 and multiples that by an ever decreasing value of one every time?
04-24-2018 08:21 AM - edited 04-24-2018 08:22 AM
Right, so if the input was 6 and a decrement of 1 every time, would the final value would be 720?
If the decrement was 2, would the answer then be 48?
04-24-2018 08:28 AM
Yep - its really a question on recursion - the VI is just calling itself, taking as its input the callers input -1.
04-24-2018 08:34 AM
Brill. Cheers chaps.
04-24-2018 10:30 AM
Do you recognize the function? It is called "Factorial", and would be written 4!. What I found interesting is that this particular implementation will return the correct value for 0! (which is 1, by definition).
Bob Schor
04-25-2018 01:35 AM - edited 04-25-2018 02:03 AM
Morning Bob,
Never heard of a Factorial so certainly didn't recognise the function. Just looked up what a factorial is on Google which quotes:
"They're just products, indicated by an exclamation mark. For instance, "four factorial" is written as "4!" and means 1×2×3×4 = 24".
As for 0! returning a correct value of 1, I clearly didn't know this either. Google also quotes:
"It can be said that an empty set can only be ordered one way, so 0! = 1"
So when I asked the question of if you take the value of 6 and decrement by 2 every time, is that not possible with a Factorial? So basically is it always a decrement of one every time, so it will always be 6x5x4x3x2x1 and nothing else?
04-25-2018 04:54 AM
Note that the implementation is old-school (=OBSOLETE).
Nowadays we can simply put the VI (as a sub VI) on the diagram. Much, much, better.