Adding factorial function.

Modifying struct functions as well.
Signed-off-by: Hela <hnciri@baylibre.com>