annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

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
Messaggio 1 di 21
5.242Visualizzazioni

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.

Messaggio 2 di 21
5.234Visualizzazioni

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
Messaggio 3 di 21
5.226Visualizzazioni

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
Messaggio 4 di 21
5.222Visualizzazioni

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
Messaggio 5 di 21
5.219Visualizzazioni

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

0 Kudos
Messaggio 6 di 21
5.209Visualizzazioni

Brill. Cheers chaps.

0 Kudos
Messaggio 7 di 21
5.204Visualizzazioni

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
Messaggio 8 di 21
5.183Visualizzazioni

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
Messaggio 9 di 21
5.149Visualizzazioni

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
Messaggio 10 di 21
5.132Visualizzazioni