Created
April 28, 2020 13:13
-
-
Save dlOuOlb/1b09d3a2690b4fb89d656e4ca11d1569 to your computer and use it in GitHub Desktop.
Greatest Common Divisor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 ) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tab-Size Preference: { default, 2, 3, 4, 6, 8 }