char *m_apm_lib_short_version_mt(char *s) { m_apm_enter(); m_apm_lib_short_version(s); m_apm_leave(); return(s); }
int main(int argc, char *argv[]) { char version_info[80]; int ct; /* declare the M_APM variables ... */ M_APM aa_mapm; M_APM bb_mapm; M_APM cc_mapm; M_APM dd_mapm; if (argc < 2) { m_apm_lib_short_version(version_info); fprintf(stdout, "Usage: primenum number\t\t\t[Version 1.3, MAPM Version %s]\n", version_info); fprintf(stdout, " find the first 10 prime numbers starting with \'number\'\n"); exit(4); } /* now initialize the M_APM variables ... */ aa_mapm = m_apm_init(); bb_mapm = m_apm_init(); cc_mapm = m_apm_init(); dd_mapm = m_apm_init(); init_working_mapm(); m_apm_set_string(dd_mapm, argv[1]); /* * if input < 3, set start point = 3 */ if (m_apm_compare(dd_mapm, MM_Three) == -1) { m_apm_copy(dd_mapm, MM_Three); } /* * make sure we start with an odd integer */ m_apm_integer_divide(aa_mapm, dd_mapm, MM_Two); m_apm_multiply(bb_mapm, MM_Two, aa_mapm); m_apm_add(aa_mapm, MM_One, bb_mapm); ct = 0; while (TRUE) { if (is_number_prime(aa_mapm)) { m_apm_to_integer_string(buffer, aa_mapm); fprintf(stdout,"%s\n",buffer); if (++ct == 10) break; } m_apm_add(cc_mapm, MM_Two, aa_mapm); m_apm_copy(aa_mapm, cc_mapm); } free_working_mapm(); m_apm_free(aa_mapm); m_apm_free(bb_mapm); m_apm_free(cc_mapm); m_apm_free(dd_mapm); m_apm_free_all_mem(); exit(0); }