Four is magic: Difference between revisions
Content added Content deleted
(→{{header|Swift}}: Remove requirement to name parameter) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 57: | Line 57: | ||
:* [[De Bruijn sequences]] |
:* [[De Bruijn sequences]] |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Nim}} |
|||
<lang 11l>V Small = [‘zero’, ‘one’, ‘two’, ‘three’, ‘four’, |
|||
‘five’, ‘six’, ‘seven’, ‘eight’, ‘nine’, |
|||
‘ten’, ‘eleven’, ‘twelve’, ‘thirteen’, ‘fourteen’, |
|||
‘fifteen’, ‘sixteen’, ‘seventeen’, ‘eighteen’, ‘nineteen’] |
|||
V Tens = [‘’, ‘’, ‘twenty’, ‘thirty’, ‘forty’, ‘fifty’, ‘sixty’, ‘seventy’, ‘eighty’, ‘ninety’] |
|||
V Illions = [‘’, ‘ thousand’, ‘ million’, ‘ billion’, ‘ trillion’, ‘ quadrillion’, ‘ quintillion’] |
|||
F say(Int64 =n) -> String |
|||
V result = ‘’ |
|||
I n < 0 |
|||
result = ‘negative ’ |
|||
n = -n |
|||
I n < 20 |
|||
result ‘’= Small[Int(n)] |
|||
E I n < 100 |
|||
result ‘’= Tens[Int(n I/ 10)] |
|||
V m = n % 10 |
|||
I m != 0 |
|||
result ‘’= ‘-’Small[Int(m)] |
|||
E I n < 1000 |
|||
result ‘’= Small[Int(n I/ 100)]‘ hundred’ |
|||
V m = n % 100 |
|||
I m != 0 |
|||
result ‘’= ‘ ’say(m) |
|||
E |
|||
V sx = ‘’ |
|||
V i = 0 |
|||
L n > 0 |
|||
V m = n % 1000 |
|||
n I/= 1000 |
|||
I m != 0 |
|||
V ix = say(m)‘’Illions[i] |
|||
I sx.len > 0 |
|||
ix ‘’= ‘ ’sx |
|||
sx = ix |
|||
i++ |
|||
result ‘’= sx |
|||
R result |
|||
F fourIsMagic(=n) |
|||
V s = say(n).capitalize() |
|||
V result = s |
|||
L n != 4 |
|||
n = s.len |
|||
s = say(n) |
|||
result ‘’= ‘ is ’s‘, ’s |
|||
R result‘ is magic.’ |
|||
L(n) [Int64(0), 4, 6, 11, 13, 75, 100, 337, -164, 7FFF'FFFF'FFFF'FFFF] |
|||
print(fourIsMagic(n))</lang> |
|||
{{out}} |
|||
<pre> |
|||
Zero is four, four is magic. |
|||
Four is magic. |
|||
Six is three, three is five, five is four, four is magic. |
|||
Eleven is six, six is three, three is five, five is four, four is magic. |
|||
Thirteen is eight, eight is five, five is four, four is magic. |
|||
Seventy-five is twelve, twelve is six, six is three, three is five, five is four, four is magic. |
|||
One hundred is eleven, eleven is six, six is three, three is five, five is four, four is magic. |
|||
Three hundred thirty-seven is twenty-six, twenty-six is ten, ten is three, three is five, five is four, four is magic. |
|||
Negative one hundred sixty-four is thirty-one, thirty-one is ten, ten is three, three is five, five is four, four is magic. |
|||
Nine quintillion two hundred twenty-three quadrillion three hundred seventy-two trillion thirty-six billion eight hundred fifty-four million seven hundred seventy-five thousand eight hundred seven is one hundred ninety-six, one hundred ninety-six is twenty-two, twenty-two is ten, ten is three, three is five, five is four, four is magic. |
|||
</pre> |
|||
=={{header|8086 Assembly}}== |
=={{header|8086 Assembly}}== |