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
JMP2rusing std.manip using std.cond using std.out fac == [: [/ 1] [: 1 - fac ×] ⍉ 0 = ?] 7 fac .nl
<> (?0 ?1 `?:) (Int ?:) <> (?n factorial) (Int ?n Int 1 fact) <> (Int 0 Int ?a fact) (?a) <> (Int ?n Int ?a fact) (?n 1 `- ?n ?a `* fact) 6 factorial
This revision created on Thu, 16 May 2024 15:05:50 by neauoire