Skip to content

Instantly share code, notes, and snippets.

@dlOuOlb
Created April 28, 2020 13:13
Show Gist options
  • Save dlOuOlb/1b09d3a2690b4fb89d656e4ca11d1569 to your computer and use it in GitHub Desktop.
Save dlOuOlb/1b09d3a2690b4fb89d656e4ca11d1569 to your computer and use it in GitHub Desktop.
Greatest Common Divisor
#include <stdio.h>
#include <stdlib.h>
typedef const int INT;
typedef const char CHAR;
typedef CHAR *const PCHAR;
typedef char **const Ppchar;
extern int main( INT, Ppchar );
#define by( _ ) for( auto _; ; )
#define at( _ ) { return _; }
#define et( _ ) else at( _ )
static int o( INT X, INT Y ) at( ( 0 > X )? Y: 0 )
static int my( INT X, INT Y, Ppchar A ) at( main( X - Y, X + A ) )
static int gcd( INT X, INT Y ) at( X? gcd( Y % X, X ): Y )
extern int main( INT X, Ppchar A )
{
if( A ) by( INT Y = -X ) by( PCHAR B = *A )
if( 0 < Y )
if( 1 < Y ) by( INT Z = Y >> 1 )
at( gcd( my( 0, Z, A ), my( Z, Y, A ) ) )
et( atoi( B ) )
et( o( Y, main( printf( "%s:%+d\n", B, my( 1, X, A ) ), 0 ) ) )
et( o( X, EXIT_FAILURE ) )
}
@dlOuOlb
Copy link
Author

dlOuOlb commented Jun 30, 2020

Tab-Size Preference: { default, 2, 3, 4, 6, 8 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment