ana_makarevich

Factorials list with accumlator

Oct 15th, 2014
585
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. % Example: {Fact 4} has to return [1 2 6 24]
  2. declare
  3. fun {Fact N}
  4.    local FactAcc in
  5.       fun {FactAcc R L}
  6.      if (R==N) then {Reverse L}
  7.      else {FactAcc R+1 (L.1*(R+1))|L}
  8.      end
  9.       end
  10.       {FactAcc 1 [1]}    
  11.    end
  12. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×