官术网_书友最值得收藏!

  • The Modern C# Challenge
  • Rod Stephens
  • 214字
  • 2021-08-13 15:23:54

15. Prime tuples

Mathematicians like playing with prime numbers, so they have come up with several different names for groupings of related primes:

  • Twin primes are primes {p, p + 2} that differ by two, such as {3, 5}. (Primes that differ by only 1 are not very interesting because 2 and 3 are the only primes that differ by 1.)
  • Cousin primes are primes {p, p + 4} that differ by 4, such as {3, 7}.
  • Sexy primes are primes {p, p + 6} that differ by 6, such as {5, 11}. (The name sexy primes is a pun because sex is Latin for six.)

You can also look for different numbers of primes with various spacings. For example, you can look for sexy pairs, sexy triples such as {7, 13, 19}, and so forth.

Write a program that checks numbers up to a maximum value, looking for primes with a given spacing and quantity. For example, the user might set the spacing to six and the number to 3 to look for groups of three primes that are each six apart, such as {5, 11, 17}.

Use your program to see what's special about groups of three or four primes that differ by 6, 12, 18, and other multiples of 3.

主站蜘蛛池模板: 阳城县| 视频| 溆浦县| 南康市| 达州市| 沈丘县| 江西省| 崇明县| 吉安市| 土默特左旗| 平远县| 通榆县| 沙田区| 阳新县| 阿城市| 习水县| 平江县| 克什克腾旗| 鄄城县| 天峻县| 当涂县| 团风县| 和平县| 贵溪市| 沾化县| 韶山市| 南陵县| 日照市| 射洪县| 东明县| 丹棱县| 赣榆县| 隆德县| 西峡县| 伽师县| 无为县| 常熟市| 台东市| 桑植县| 义乌市| 阳新县|