Integer sequence: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (Undo revision 324717 by Drkameleon (talk)) |
m (→{{header|Phix}}: added syntax colouring the hard way) |
||
Line 1,674: | Line 1,674: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
This will crash at 1,073,741,824 on 32 bit, 4,611,686,018,427,387,904 on 64-bit: |
This will crash at 1,073,741,824 on 32 bit, or 4,611,686,018,427,387,904 on 64-bit: |
||
<lang Phix> |
<!--<lang Phix>--> |
||
<span style="color: #004080;">integer</span> <span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span> |
|||
while 1 do |
|||
<span style="color: #008080;">while</span> <span style="color: #000000;">1</span> <span style="color: #008080;">do</span> |
|||
?i |
|||
<span style="color: #0000FF;">?</span><span style="color: #000000;">i</span> |
|||
i += 1 |
|||
<span style="color: #000000;">i</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span> |
|||
end while</lang> |
|||
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
|||
<!--</lang>--> |
|||
This will stall at 9,007,199,254,740,992 on 32-bit, and about twice the above on 64-bit. |
This will stall at 9,007,199,254,740,992 on 32-bit, and about twice the above on 64-bit. |
||
(after ~15 or 19 digits of precision, adding 1 will simply cease to have any effect) |
(after ~15 or 19 digits of precision, adding 1 will simply cease to have any effect) |
||
<lang Phix> |
<!--<lang Phix>--> |
||
<span style="color: #004080;">atom</span> <span style="color: #000000;">a</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span> |
|||
while 1 do |
|||
<span style="color: #008080;">while</span> <span style="color: #000000;">1</span> <span style="color: #008080;">do</span> |
|||
?a |
|||
<span style="color: #0000FF;">?</span><span style="color: #000000;">a</span> |
|||
a += 1 |
|||
<span style="color: #000000;">a</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span> |
|||
end while</lang> |
|||
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
|||
<!--</lang>--> |
|||
{{libheader|Phix/mpfr}} |
{{libheader|Phix/mpfr}} |
||
This will probably carry on until the number has over 300 million digits (32-bit, you can |
This will probably carry on until the number has over 300 million digits (32-bit, you can |
||
square that on 64-bit) which would probably take zillions of times longer than the |
square that on 64-bit) which would probably take zillions of times longer than the |
||
universe has already existed, if your hardware/OS/power grid kept going that long. |
universe has already existed, if your hardware/OS/power grid kept going that long. |
||
<lang Phix> |
<!--<lang Phix>--> |
||
<span style="color: #008080;">include</span> <span style="color: #000000;">mpfr</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
|||
mpz b = mpz_init(0) |
|||
<span style="color: #7060A8;">mpz</span> <span style="color: #000000;">b</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mpz_init</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">)</span> |
|||
while true do |
|||
<span style="color: #008080;">while</span> <span style="color: #004600;">true</span> <span style="color: #008080;">do</span> |
|||
mpz_add_ui(b,b,1) |
|||
<span style="color: #7060A8;">mpz_add_ui</span><span style="color: #0000FF;">(</span><span style="color: #000000;">b</span><span style="color: #0000FF;">,</span><span style="color: #000000;">b</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span> |
|||
mpfr_printf(1,"%Zd\n",b) |
|||
<span style="color: #7060A8;">mpfr_printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%Zd\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">b</span><span style="color: #0000FF;">)</span> |
|||
end while</lang> |
|||
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
|||
<!--</lang>--> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |