The GCD of the numerator and denominator are > 1 for 806 numbers between 1 and 2016 as follows:
a=1;p=0; c= a^2 - 9; d=a^2 - 4;f=gcd(c, d);e=if(gcd(c,d)>1, goto6, goto8);printa,", ", ;p=p+1;a++;if(a<=2016, goto2, 0);print" Total = ",p
2 3 7 8 12 13 17 18 22 23 27 28 32 33 37 38 42 43 47 48 52 53 57 58 62 63 67 68 72 73 77 78 82 83 87 88 92 93 97 98 102 103 107 108 112 113 117 118 122 123 127 128 132 133 137 138 142 143 147 148 152 153 157 158 162 163 167 168 172 173 177 178 182 183 187 188 192 193 197 198 202 203 207 208 212 213 217 218 222 223 227 228 232 233 237 238 242 243 247 248 252 253 257 258 262 263 267 268 272 273 277 278 282 283 287 288 292 293 297 298 302 303 307 308 312 313 317 318 322 323 327 328 332 333 337 338 342 343 347 348 352 353 357 358 362 363 367 368 372 373 377 378 382 383 387 388 392 393 397 398 402 403 407 408 412 413 417 418 422 423 427 428 432 433 437 438 442 443 447 448 452 453 457 458 462 463 467 468 472 473 477 478 482 483 487 488 492 493 497 498 502 503 507 508 512 513 517 518 522 523 527 528 532 533 537 538 542 543 547 548 552 553 557 558 562 563 567 568 572 573 577 578 582 583 587 588 592 593 597 598 602 603 607 608 612 613 617 618 622 623 627 628 632 633 637 638 642 643 647 648 652 653 657 658 662 663 667 668 672 673 677 678 682 683 687 688 692 693 697 698 702 703 707 708 712 713 717 718 722 723 727 728 732 733 737 738 742 743 747 748 752 753 757 758 762 763 767 768 772 773 777 778 782 783 787 788 792 793 797 798 802 803 807 808 812 813 817 818 822 823 827 828 832 833 837 838 842 843 847 848 852 853 857 858 862 863 867 868 872 873 877 878 882 883 887 888 892 893 897 898 902 903 907 908 912 913 917 918 922 923 927 928 932 933 937 938 942 943 947 948 952 953 957 958 962 963 967 968 972 973 977 978 982 983 987 988 992 993 997 998 1002 1003 1007 1008 1012 1013 1017 1018 1022 1023 1027 1028 1032 1033 1037 1038 1042 1043 1047 1048 1052 1053 1057 1058 1062 1063 1067 1068 1072 1073 1077 1078 1082 1083 1087 1088 1092 1093 1097 1098 1102 1103 1107 1108 1112 1113 1117 1118 1122 1123 1127 1128 1132 1133 1137 1138 1142 1143 1147 1148 1152 1153 1157 1158 1162 1163 1167 1168 1172 1173 1177 1178 1182 1183 1187 1188 1192 1193 1197 1198 1202 1203 1207 1208 1212 1213 1217 1218 1222 1223 1227 1228 1232 1233 1237 1238 1242 1243 1247 1248 1252 1253 1257 1258 1262 1263 1267 1268 1272 1273 1277 1278 1282 1283 1287 1288 1292 1293 1297 1298 1302 1303 1307 1308 1312 1313 1317 1318 1322 1323 1327 1328 1332 1333 1337 1338 1342 1343 1347 1348 1352 1353 1357 1358 1362 1363 1367 1368 1372 1373 1377 1378 1382 1383 1387 1388 1392 1393 1397 1398 1402 1403 1407 1408 1412 1413 1417 1418 1422 1423 1427 1428 1432 1433 1437 1438 1442 1443 1447 1448 1452 1453 1457 1458 1462 1463 1467 1468 1472 1473 1477 1478 1482 1483 1487 1488 1492 1493 1497 1498 1502 1503 1507 1508 1512 1513 1517 1518 1522 1523 1527 1528 1532 1533 1537 1538 1542 1543 1547 1548 1552 1553 1557 1558 1562 1563 1567 1568 1572 1573 1577 1578 1582 1583 1587 1588 1592 1593 1597 1598 1602 1603 1607 1608 1612 1613 1617 1618 1622 1623 1627 1628 1632 1633 1637 1638 1642 1643 1647 1648 1652 1653 1657 1658 1662 1663 1667 1668 1672 1673 1677 1678 1682 1683 1687 1688 1692 1693 1697 1698 1702 1703 1707 1708 1712 1713 1717 1718 1722 1723 1727 1728 1732 1733 1737 1738 1742 1743 1747 1748 1752 1753 1757 1758 1762 1763 1767 1768 1772 1773 1777 1778 1782 1783 1787 1788 1792 1793 1797 1798 1802 1803 1807 1808 1812 1813 1817 1818 1822 1823 1827 1828 1832 1833 1837 1838 1842 1843 1847 1848 1852 1853 1857 1858 1862 1863 1867 1868 1872 1873 1877 1878 1882 1883 1887 1888 1892 1893 1897 1898 1902 1903 1907 1908 1912 1913 1917 1918 1922 1923 1927 1928 1932 1933 1937 1938 1942 1943 1947 1948 1952 1953 1957 1958 1962 1963 1967 1968 1972 1973 1977 1978 1982 1983 1987 1988 1992 1993 1997 1998 2002 2003 2007 2008 2012 2013 Total = 806
Ummmmmmmmmmmmmmmmmmmm...
This was a question on a 40 minute test with 30 questions, and I'm not exactly sure this would work in that time. But I really think you spent a lot of effort doing that and that's really great.
Sorry but your program is not working as intended.
if n=2, the numerator is -5 and the denominator is 0, These do not have a GCF greater than 1.
No, the GCF can't be 2, (even withstanding the zero on the bottom line), for whatever the value of n, if the top line is even the bottom line will be odd and if the bottom line is even then the top line will be odd.
Suppose that the GCF is k, and that
\(\displaystyle n^{2}-9=m_{1}k\dots \dots(1)\\ \text{and}\\ n^{2}-4=m_{2}k\dots \dots(2)\)
Subtracting (1) from (2),
\(\displaystyle 5=m_{2}k-m_{1}k=(m_{2}-m_{1})k,\)
so either
\(\displaystyle m_{2}-m_{1}=5\text{ and }k=1, \text{ (which is of no interest)}\)
or
\(\displaystyle m_{2}-m_{1}=1\text{ and }k=5, \text{ (which is).}\)
If k = 5, then, from (1), \(\displaystyle 9+5m_{1} = n^{2}.\)
(Substitution into (2) leads to the same equation.)
Beginning with m1 = 1, the lhs side runs through the numbers, 14, 19, 24, 29, 34, 39, ...
so what we are looking for are squares with final digit 4 or 9.
The first one is 49, n = 7, and the next 64, n = 8.
After that, 144, n = 12, and then 169, n = 13.
Now that's interesting, in pairs 5 apart ......... .