Integer sequence: Difference between revisions

→‎{{header|C}}: Show OpenSSL.
(Add Brat solution)
(→‎{{header|C}}: Show OpenSSL.)
Line 47:
 
=={{header|C}}==
<tt>uint32_t</tt> has a range from 0 to 4294967295. After the program reaches 4294967295, it will overflow to 0.
 
<lang c>#include <stdio.h>
#include <stdint.h>
Line 72 ⟶ 74:
return 0;
}</lang>
 
==={{libheader|OpenSSL}}===
OpenSSL provides arbitrarily large integers.
 
<lang c>#include <openssl/bn.h> /* BN_*() */
#include <openssl/err.h> /* ERR_*() */
#include <stdio.h> /* fprintf(), puts() */
 
void
fail(const char *message)
{
unsigned long code;
 
fprintf(stderr, "%s: error\n", message);
while (code = ERR_get_error())
fprintf(stderr, " %s\n", ERR_error_string(code, NULL));
exit(1);
}
 
int
main()
{
BIGNUM i;
char *s;
 
BN_init(&i);
for (;;) {
if (BN_add_word(&i, 1) == 0)
fail("BN_add_word");
s = BN_bn2dec(&i);
if (s == NULL)
fail("BN_bn2dec");
puts(s);
OPENSSL_free(s);
}
/* NOTREACHED */
}</lang>
 
=={{header|C sharp|C#}}==
<lang csharp>using System;
Anonymous user