factorial[n_Integer?NonNegative] :=
    Module[{i = 0, k = 1},
        While[i != n,
            k = k*(i+1);
            i = i+1;
        ];
        k
    ]
