Skip to content

Instantly share code, notes, and snippets.

@Sam-Belliveau
Last active December 17, 2018 02:03
Show Gist options
  • Select an option

  • Save Sam-Belliveau/15ce70a5495d5903bbba07ff3b390c93 to your computer and use it in GitHub Desktop.

Select an option

Save Sam-Belliveau/15ce70a5495d5903bbba07ff3b390c93 to your computer and use it in GitHub Desktop.
A counter thats faster than using an int and printf. It also never stops counting until 10^2^24, but you can increase the max int without slowing it down like with gmp.
#include <stdio.h>
#include <stdlib.h>
int main(){char *d,*n=calloc(0x1000000,1);*n=48;for(;;){d=n;if(*d!=57)++*d;else{while(*d
==57)*(d++)=48;if(*d)++*d;else*d=49;}while(*++d);while(d--!=n)putchar(*d);putchar(13);}}
#include <stdio.h>
#include <stdlib.h>
#define FLET '0' /* First Letter */
#define LLET '9' /* Last Letter */
int main()
{
char* d;
char* n = calloc(0x1000000,1);
*n = '0';
/* Loop */
while(1)
{
/* Make Pointer To Begining */
d = n;
/* If first digit is not 9, stop */
if(*d != LLET) { ++*d; }
else
{
/* While the digit is 9, carry */
while(*d == LLET) { *(d++) = FLET; }
/* If you need to add a new digit */
/* Then make room for a new digit */
if(*d == '\0') { *d = FLET + 1; }
else { ++*d; } /* Else just add 1 */
}
/* Print String Backwards*/
while(*++d){} /* Get to the end of the string */
/* Print string letter by letter backwards */
while(d-- != n) { putchar(*d); }
/* Return to the begining of the line */
putchar('\r');
}
}
#include <stdio.h>
#include <stdlib.h>
int main(){char *d,*n=calloc(0x1000000,1);*n=48;for(;;){d=n;if(*d!=57){++*d;}else{while(*d==
57){*(d++)=48;}if(*d){++*d;}else{*d=49;}}while(*++d);while(d--!=n){putchar(*d);}putchar(13);}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment