Factorial in INTERCAL
Example for versions
J-INTERCAL 0.11,
J-INTERCAL 0.12,
c-intercal 28.0
This example uses iterative factorial definition. The looping part is similar to Fibonacci example, the body differs, but only a little bit. Note usage of :
prefix for variables instead of .
— the former means 32-bit variables, and the latter — 16-bit ones. The output looks as follows (numbers go in pairs, n and n!, and each number takes two lines to be written):
_
I
I
I
II
II
III
VI
IV
XXIV
V
CXX
VI
DCCXX
VII
_
VXL
VIII
__
XLCCCXX
IX
_____
CCCLXMMDCCCLXXX
X
___________
MMMDCXXVIIIDCCC
XI
_____
xxxixCMXVIDCCC
XII
cdlxxixMDC
XIII
___
mcmxxxMMLMMMDIV
XIV
_____
mcclxxviiiCMXLVCCLXXX
XV
____
mmivCCCXXVI
XVI
_______
mmivCLXXXIXCLXXXIV
C-INTERCAL uses Roman notation, in which a bar over a numeral multiplies its value by 1000, and writing a letter in lowercase multiplies its value by 1000000.
DO .9 <- #17
DO :10 <- #0
DO :11 <- #1
DO :2 <- :10
(1) PLEASE READ OUT :10
PLEASE READ OUT :11
DO :1 <- #1
PLEASE (1509) NEXT
DO :10 <- :3
DO :2 <- :10
DO :1 <- :11
PLEASE (1549) NEXT
DO :11 <- :3
DO (3) NEXT
DO (1) NEXT
(3) DO (4) NEXT
PLEASE GIVE UP
(4) DO .1 <- .9
DO .2 <- #1
PLEASE (1010) NEXT
DO .9 <- .3
DO .1 <- '.9~.9'~#1
PLEASE (1020) NEXT
DO RESUME .1
Comments
]]>blog comments powered by Disqus
]]>