diff options
| author | Walt Mankowski <waltman@pobox.com> | 2022-07-17 10:56:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-17 10:56:32 -0400 |
| commit | 45f08a5e1866678d6ac9e42e30afd3a1d5d53fe6 (patch) | |
| tree | 3f77242a19900a639e6cbc7e6074958bfc465c35 /challenge-173/deadmarshal/lua/ch-2.lua | |
| parent | 37698ededed833b0c0d49ac0e44d5d01025e8b0e (diff) | |
| parent | ef0acd3af69b9cc99dea234b2ab4670e52bb506e (diff) | |
| download | perlweeklychallenge-club-45f08a5e1866678d6ac9e42e30afd3a1d5d53fe6.tar.gz perlweeklychallenge-club-45f08a5e1866678d6ac9e42e30afd3a1d5d53fe6.tar.bz2 perlweeklychallenge-club-45f08a5e1866678d6ac9e42e30afd3a1d5d53fe6.zip | |
Merge branch 'master' into branch-for-challenge-173-python
Diffstat (limited to 'challenge-173/deadmarshal/lua/ch-2.lua')
| -rw-r--r-- | challenge-173/deadmarshal/lua/ch-2.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-173/deadmarshal/lua/ch-2.lua b/challenge-173/deadmarshal/lua/ch-2.lua new file mode 100644 index 0000000000..1cca518763 --- /dev/null +++ b/challenge-173/deadmarshal/lua/ch-2.lua @@ -0,0 +1,24 @@ +-- https://github.com/edubart/lua-bint +-- To install this library: luarocks install bint +local bint = require 'bint'(1024) + +local function product(t, last) + assert(type(t) == 'table' and + type(last) == 'number', + 't, last must be table, number, number respectively!') + local prod = bint(1) + for i=1, last do prod = prod * t[i] end + return prod +end + +local function sylvesters_sequence() + local t = {2,3} + while(#t ~= 10) do + t[#t+1] = bint(product(t, #t) + 1) + end + return t +end + +local t = sylvesters_sequence() +for i=1, #t do print(t[i]) end + |
