/////////////////////////////////////////////////////////////////////////////// // File : pgcd.c // Date : November 2017 // Author : Alain Greiner /////////////////////////////////////////////////////////////////////////////// // This single thread interactive application computes the PGCD. /////////////////////////////////////////////////////////////////////////////// #include #include #include ///////////////// void main( void ) { int opx; int opy; unsigned long long cycle; get_cycle( &cycle ); printf( "\n\n[PGCD] starts / cycle %d\n", (unsigned int)cycle ); while (1) { printf("\n*******************\n"); printf("operand X = "); opx = getint(); printf("\n"); printf("operand Y = "); opy = getint(); printf("\n"); if( (opx == 0) || (opy == 0) ) { printf("operands must be positive and larger than 0 => exit\n"); exit( 0 ); } else { while (opx != opy) { if(opx > opy) opx = opx - opy; else opy = opy - opx; } printf("pgcd = %d", opx); } } } // end pgcd