a-spec Pub

Implementation for factorial

$when:: a.fact (n == 0)
   . (payload=1)

$when:: a.fact (n > 0)
   a.fact (n<-(n - 1))
   . (payload=(payload * n))

In pseudocode, it would look like this:

if(n == 0) fact = 1;
else fact = n * fact(n-1)


Was this useful?    

By: Razie | 2019-06-01 | Tags: spec , dsl


Viewed 77 times ( | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2020, all rights reserved.