ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CLD-R Exam 1, Question 19

Just looking at question 19 of the CLD-R exam 1. PLease can somebody tell me why the answer is c.24?

 

CLD-R Question 19.PNG

0 Kudos
Message 1 of 21
(5,139 Views)

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.

Message 2 of 21
(5,131 Views)

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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 21
(5,123 Views)

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?

0 Kudos
Message 4 of 21
(5,119 Views)

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?

 

0 Kudos
Message 5 of 21
(5,116 Views)

Yep - its really a question on recursion - the VI is just calling itself, taking as its input the callers input -1.

0 Kudos
Message 6 of 21
(5,106 Views)

Brill. Cheers chaps.

0 Kudos
Message 7 of 21
(5,101 Views)

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

0 Kudos
Message 8 of 21
(5,080 Views)

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?

0 Kudos
Message 9 of 21
(5,046 Views)

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.

0 Kudos
Message 10 of 21
(5,029 Views)