Concatenative topics
Concatenative meta
Other languages
Meta
A factorial is a function in mathematics that multiplies a number by every number that precedes it.
int main(){ int x = 7; printf("The factorial of the number is %d", fac(x)); return 0; } int fac(int y) { if (y == 0) return 1; return y * fac(y - 1); }
@on-reset ( -> ) #0007 fac #010e DEO BRK @fac ( n* -: res* ) ORAk ?{ POP2 #0001 JMP2r } DUP2 #0001 SUB2 fac MUL2 JMP2r
using std.manip using std.cond using std.out fac == [: [/ 1] [: 1 - fac ×] ⍉ 0 = ?] 7 fac .nl
This revision created on Thu, 21 Mar 2024 04:47:39 by vatsjijj (Change 5 to 7.)