Sunday, September 25, 2016

How to implement Factorial Program using C/AL CODE in MS Dynamics NAV?

Concept:

Factorial is program in which n multiplies n-1 itself till it comes to 1. For Eg.

6! = 6*5*4*3*2*1

In NAV we use generally use C/AL programming so here we will use looping in NAV.


Step:1 Create a Codeunit in NAV Development environment.

Step 2. Create 3 global variable.

Step3. Then writing the coe as below will generate the Factorial of a number.

This one is simple.

Mile stone journey starts with a single step.


I will start with more complex program soon.






But in this example we have taken the counter in increasing order by using TO we can also do it in decreasing counter using DOWNTO For Eg.


1.(a)Factorial Program using while Loop.

While Loop Syntax must be followed with Care else we will move in an infinite loop.



1.(c) Factorial program using REPEAT UNTIL






1 comment: