--- projs/dtats/trunk/projs/2018/20180707_cgi_web_tools_aux_exe/dtats_cgi_aux_arith_large/subfunc_gcd.c 2018/07/15 19:48:41 206 +++ projs/dtats/trunk/projs/2018/20180707_cgi_web_tools_aux_exe/dtats_cgi_aux_arith_large/subfunc_gcd.c 2018/07/15 21:50:56 207 @@ -28,8 +28,8 @@ //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //SOFTWARE. //******************************************************************************** -//This module is the GCD subfunction of a general-purpose CGI-BIN program to support -//number theory demonstration applications. +//This module is the GCD subfunction of a general-purpose CGI-BIN program to support +//number theory demonstration applications. // //INPUT PARAMETERS //---------------- @@ -52,7 +52,7 @@ // EQ : Other or unspecified error. // //[02] The fully normalized first integer entered. This means it has been -// stripped of all weird characters, etc. This can be used by the +// stripped of all weird characters, etc. This can be used by the // PHP script to repopulate the form boxes. //[03] The fully normalized second integer entered. // @@ -75,7 +75,7 @@ //this program will contain a number of lines which is a multiple of 5. // //The return value (exit code) from this subfunction is always 0. -// +// #define MODULE_SUBFUNC_GCD @@ -109,7 +109,7 @@ return(0); } - //Copy the command-line arguments to a safe place where we can manipulate them. + //Copy the command-line arguments to a safe place where we can manipulate them. //Leave 2 characters of space in case we assign a "0". arg1 = (char *)malloc((AUXFUNCS_size_t_max(1, strlen(argv[2])) + 1) * sizeof(char)); arg2 = (char *)malloc((AUXFUNCS_size_t_max(1, strlen(argv[3])) + 1) * sizeof(char)); @@ -167,10 +167,10 @@ //We assume at this point that we will be successful. Output //the header stuff. printf("S\n"); - mpz_out_str(stdout, 10, alg_a); - printf("\n"); - mpz_out_str(stdout, 10, alg_b); - printf("\n"); + mpz_out_str(stdout, 10, alg_a); + printf("\n"); + mpz_out_str(stdout, 10, alg_b); + printf("\n"); //We require as an initial condition that a >= b. Make //that happen. @@ -190,36 +190,36 @@ { //We are at next round. round++; - + //Values for this round inherited from the last one. mpz_set(alg_a, alg_b); mpz_set(alg_b, alg_amodb); - + //Calculate the quotient and remainder. mpz_fdiv_qr(alg_adivb, alg_amodb, alg_a, alg_b); //Output all the data from the round. printf("%d\n", round); - mpz_out_str(stdout, 10, alg_a); - printf("\n"); - mpz_out_str(stdout, 10, alg_b); - printf("\n"); - mpz_out_str(stdout, 10, alg_adivb); - printf("\n"); - mpz_out_str(stdout, 10, alg_amodb); - printf("\n"); + mpz_out_str(stdout, 10, alg_a); + printf("\n"); + mpz_out_str(stdout, 10, alg_b); + printf("\n"); + mpz_out_str(stdout, 10, alg_adivb); + printf("\n"); + mpz_out_str(stdout, 10, alg_amodb); + printf("\n"); } while((round < 2000) && (mpz_sgn(alg_amodb) > 0)); //The GCD canonically will be the last non-zero remainder. - mpz_out_str(stdout, 10, alg_b); - printf("\n"); + mpz_out_str(stdout, 10, alg_b); + printf("\n"); //Finally, we output the trailing "S". printf("S\n"); return(0); - } + } //******************************************************************************** // End of SUBFUNC_GCD.C.