Concatenative language
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); } }] = [[Tal|Uxntal]] = [{@on-reset ( -> ) #0007 fact #010e DEO BRK @fact ( n* -- res* ) ORAk ?{ INC2 JMP2r } DUP2 #0001 SUB2 fact MUL2 JMP2r}] = [[Titan]] = [{using std.manip using std.cond using std.out fac == [: [/ 1] [: 1 - fac ×] ⍉ 0 = ?] 7 fac .nl}] = [[Modal]] = [{ <> (?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 }] = [[Quadrate]] = [{fn fac(y:i64 -- result:i64) { dup 0 == if { drop 1 } else { dup -- fac * } } fn main() { "The factorial of the number is " print 7 fac print nl }}]
Describe this revision:
Save