{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":44305,"title":"5 Prime Numbers","description":"Your function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\r\n\r\nFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\r\n\r\n p = [61,67,71,73,79, ... 149,151,157,163, ... 241,251,257,263, ... 349,353,359,367, ... 983,991,997]\r\n\r\nThis set contains at least five numbers that contain a five; the first five are:\r\n\r\n p5 = [151,157,251,257,353]\r\n\r\nwhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; transform-origin: 420.4375px 118px; vertical-align: baseline; perspective-origin: 420.4375px 118px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; transform-origin: 309px 31.5px; white-space: pre-wrap; perspective-origin: 309px 31.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p = [61,67,71,73,79, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e149,151,157,163, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e241,251,257,263, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e349,353,359,367, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e983,991,997]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThis set contains at least five numbers that contain a five; the first five are:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p5 = [151,157,251,257,353]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 21px; white-space: pre-wrap; perspective-origin: 309px 21px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = five_primes(n_min,n_max)\r\n  y = [];\r\nend","test_suite":"%%\r\nn_min = 60;\r\nn_max = 1000;\r\ny_correct = [151,157,251,257,353];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 60;\r\nn_max = 300;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 200;\r\ny_correct = [5,53,59,151,157];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 100;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 600;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 555;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 500000000;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5020;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5200;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 55555555;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 55555;\r\nn_max = 56789;\r\ny_correct = [55579,55589,55603,55609,55619];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 987654321;\r\nn_max = 988777666;\r\ny_correct = [987654323,987654337,987654347,987654359,987654361];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":453,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T18:33:05.000Z","updated_at":"2026-04-06T09:57:52.000Z","published_at":"2017-10-16T01:45:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ p = [61,67,71,73,79, … 149,151,157,163, … 241,251,257,263, … 349,353,359,367, … 983,991,997]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis set contains at least five numbers that contain a five; the first five are:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ p5 = [151,157,251,257,353]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1688,"title":"Prime Sequences: AP-k Minimum Final Value","description":"Welcome to Fun with Primes. Today we will find the Minimum Final Value AP-k sequences for n_max=3:12 given the primorial and knowledge that the solution is of the form a + b * k# * n.\r\n\r\nThe AP-k of n sequence is n_max+1 primes of the form a + b * k# * n where n=0:n_max. The value of \"a\" is a prime and k# is the primorial.\r\n\r\nThe primorial k# is the product of all primes ≤ k, e.g. 10# = 2 · 3 · 5 · 7.\r\n\r\n*Input:* (k, n_max) \r\n\r\n*Output:* [a, b] for the equation Prime = a + b * k# * n,  n=0:n_max; Prime(n_max) must be the optimum minimum.\r\n\r\n*Value Range Limits:* [a\u003c150,000 , b\u003c8 ]\r\n\r\n*Example:* \r\n\r\n(13, 13) yields [31385539,14 ]; 31385539 + 14·13#·n (End Prime 36850999) \r\n\r\n*Commentary:*\r\n\r\n(13, 16) has a non-minimal end [17, 11387819007325752 ] to give Primes=17 + 11387819007325752·13#·n\r\n\r\nThe current June 2013 record for n is 25 via PrimeGrid:  43142746595714191 + 23681770·23#·n\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eWelcome to Fun with Primes. Today we will find the Minimum Final Value AP-k sequences for n_max=3:12 given the primorial and knowledge that the solution is of the form a + b * k# * n.\u003c/p\u003e\u003cp\u003eThe AP-k of n sequence is n_max+1 primes of the form a + b * k# * n where n=0:n_max. The value of \"a\" is a prime and k# is the primorial.\u003c/p\u003e\u003cp\u003eThe primorial k# is the product of all primes ≤ k, e.g. 10# = 2 · 3 · 5 · 7.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e (k, n_max)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e [a, b] for the equation Prime = a + b * k# * n,  n=0:n_max; Prime(n_max) must be the optimum minimum.\u003c/p\u003e\u003cp\u003e\u003cb\u003eValue Range Limits:\u003c/b\u003e [a\u0026lt;150,000 , b\u0026lt;8 ]\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e(13, 13) yields [31385539,14 ]; 31385539 + 14·13#·n (End Prime 36850999)\u003c/p\u003e\u003cp\u003e\u003cb\u003eCommentary:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e(13, 16) has a non-minimal end [17, 11387819007325752 ] to give Primes=17 + 11387819007325752·13#·n\u003c/p\u003e\u003cp\u003eThe current June 2013 record for n is 25 via PrimeGrid:  43142746595714191 + 23681770·23#·n\u003c/p\u003e","function_template":"function [a,b]=APk_min_end(k,n)\r\n% a+b*k#*(0:n) are all primes\r\n a=0;\r\n b=0;\r\nend\r\n","test_suite":"tic\r\nn=3; p=3;\r\n[a,b]=APk_min_end(p,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(p))*n,23))\r\n%%\r\nn=4; p=3;\r\n[a,b]=APk_min_end(p,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(p))*n,29))\r\n%%\r\nn=5; p=5;\r\n[a,b]=APk_min_end(p,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(p))*n,157))\r\n%%\r\nn=6; k=5;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,907))\r\n%%\r\nn=7; k=7;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,1669))\r\n%%\r\nn=8; k=7;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,1879))\r\n%%\r\nn=9; k=7;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,2089))\r\n%%\r\nn=10; k=11;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,249037))\r\n%%\r\nn=11; k=11;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,262897))\r\n%%\r\nn=12; k=13;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,725663))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2013-06-30T03:36:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-06-30T03:04:32.000Z","updated_at":"2013-06-30T04:28:44.000Z","published_at":"2013-06-30T03:36:26.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWelcome to Fun with Primes. Today we will find the Minimum Final Value AP-k sequences for n_max=3:12 given the primorial and knowledge that the solution is of the form a + b * k# * n.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe AP-k of n sequence is n_max+1 primes of the form a + b * k# * n where n=0:n_max. The value of \\\"a\\\" is a prime and k# is the primorial.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe primorial k# is the product of all primes ≤ k, e.g. 10# = 2 · 3 · 5 · 7.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (k, n_max)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [a, b] for the equation Prime = a + b * k# * n, n=0:n_max; Prime(n_max) must be the optimum minimum.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eValue Range Limits:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [a\u0026lt;150,000 , b\u0026lt;8 ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(13, 13) yields [31385539,14 ]; 31385539 + 14·13#·n (End Prime 36850999)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCommentary:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(13, 16) has a non-minimal end [17, 11387819007325752 ] to give Primes=17 + 11387819007325752·13#·n\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe current June 2013 record for n is 25 via PrimeGrid: 43142746595714191 + 23681770·23#·n\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44305,"title":"5 Prime Numbers","description":"Your function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\r\n\r\nFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\r\n\r\n p = [61,67,71,73,79, ... 149,151,157,163, ... 241,251,257,263, ... 349,353,359,367, ... 983,991,997]\r\n\r\nThis set contains at least five numbers that contain a five; the first five are:\r\n\r\n p5 = [151,157,251,257,353]\r\n\r\nwhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; transform-origin: 420.4375px 118px; vertical-align: baseline; perspective-origin: 420.4375px 118px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; transform-origin: 309px 31.5px; white-space: pre-wrap; perspective-origin: 309px 31.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p = [61,67,71,73,79, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e149,151,157,163, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e241,251,257,263, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e349,353,359,367, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e983,991,997]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThis set contains at least five numbers that contain a five; the first five are:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p5 = [151,157,251,257,353]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 21px; white-space: pre-wrap; perspective-origin: 309px 21px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = five_primes(n_min,n_max)\r\n  y = [];\r\nend","test_suite":"%%\r\nn_min = 60;\r\nn_max = 1000;\r\ny_correct = [151,157,251,257,353];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 60;\r\nn_max = 300;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 200;\r\ny_correct = [5,53,59,151,157];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 100;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 600;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 555;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 500000000;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5020;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5200;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 55555555;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 55555;\r\nn_max = 56789;\r\ny_correct = [55579,55589,55603,55609,55619];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 987654321;\r\nn_max = 988777666;\r\ny_correct = [987654323,987654337,987654347,987654359,987654361];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":453,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T18:33:05.000Z","updated_at":"2026-04-06T09:57:52.000Z","published_at":"2017-10-16T01:45:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ p = [61,67,71,73,79, … 149,151,157,163, … 241,251,257,263, … 349,353,359,367, … 983,991,997]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis set contains at least five numbers that contain a five; the first five are:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ p5 = [151,157,251,257,353]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1688,"title":"Prime Sequences: AP-k Minimum Final Value","description":"Welcome to Fun with Primes. Today we will find the Minimum Final Value AP-k sequences for n_max=3:12 given the primorial and knowledge that the solution is of the form a + b * k# * n.\r\n\r\nThe AP-k of n sequence is n_max+1 primes of the form a + b * k# * n where n=0:n_max. The value of \"a\" is a prime and k# is the primorial.\r\n\r\nThe primorial k# is the product of all primes ≤ k, e.g. 10# = 2 · 3 · 5 · 7.\r\n\r\n*Input:* (k, n_max) \r\n\r\n*Output:* [a, b] for the equation Prime = a + b * k# * n,  n=0:n_max; Prime(n_max) must be the optimum minimum.\r\n\r\n*Value Range Limits:* [a\u003c150,000 , b\u003c8 ]\r\n\r\n*Example:* \r\n\r\n(13, 13) yields [31385539,14 ]; 31385539 + 14·13#·n (End Prime 36850999) \r\n\r\n*Commentary:*\r\n\r\n(13, 16) has a non-minimal end [17, 11387819007325752 ] to give Primes=17 + 11387819007325752·13#·n\r\n\r\nThe current June 2013 record for n is 25 via PrimeGrid:  43142746595714191 + 23681770·23#·n\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eWelcome to Fun with Primes. Today we will find the Minimum Final Value AP-k sequences for n_max=3:12 given the primorial and knowledge that the solution is of the form a + b * k# * n.\u003c/p\u003e\u003cp\u003eThe AP-k of n sequence is n_max+1 primes of the form a + b * k# * n where n=0:n_max. The value of \"a\" is a prime and k# is the primorial.\u003c/p\u003e\u003cp\u003eThe primorial k# is the product of all primes ≤ k, e.g. 10# = 2 · 3 · 5 · 7.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e (k, n_max)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e [a, b] for the equation Prime = a + b * k# * n,  n=0:n_max; Prime(n_max) must be the optimum minimum.\u003c/p\u003e\u003cp\u003e\u003cb\u003eValue Range Limits:\u003c/b\u003e [a\u0026lt;150,000 , b\u0026lt;8 ]\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e(13, 13) yields [31385539,14 ]; 31385539 + 14·13#·n (End Prime 36850999)\u003c/p\u003e\u003cp\u003e\u003cb\u003eCommentary:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e(13, 16) has a non-minimal end [17, 11387819007325752 ] to give Primes=17 + 11387819007325752·13#·n\u003c/p\u003e\u003cp\u003eThe current June 2013 record for n is 25 via PrimeGrid:  43142746595714191 + 23681770·23#·n\u003c/p\u003e","function_template":"function [a,b]=APk_min_end(k,n)\r\n% a+b*k#*(0:n) are all primes\r\n a=0;\r\n b=0;\r\nend\r\n","test_suite":"tic\r\nn=3; p=3;\r\n[a,b]=APk_min_end(p,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(p))*n,23))\r\n%%\r\nn=4; p=3;\r\n[a,b]=APk_min_end(p,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(p))*n,29))\r\n%%\r\nn=5; p=5;\r\n[a,b]=APk_min_end(p,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(p))*n,157))\r\n%%\r\nn=6; k=5;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,907))\r\n%%\r\nn=7; k=7;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,1669))\r\n%%\r\nn=8; k=7;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,1879))\r\n%%\r\nn=9; k=7;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,2089))\r\n%%\r\nn=10; k=11;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,249037))\r\n%%\r\nn=11; k=11;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,262897))\r\n%%\r\nn=12; k=13;\r\n[a,b]=APk_min_end(k,n);\r\ntoc\r\nassert(isequal(a+b*prod(primes(k))*n,725663))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2013-06-30T03:36:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-06-30T03:04:32.000Z","updated_at":"2013-06-30T04:28:44.000Z","published_at":"2013-06-30T03:36:26.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWelcome to Fun with Primes. Today we will find the Minimum Final Value AP-k sequences for n_max=3:12 given the primorial and knowledge that the solution is of the form a + b * k# * n.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe AP-k of n sequence is n_max+1 primes of the form a + b * k# * n where n=0:n_max. The value of \\\"a\\\" is a prime and k# is the primorial.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe primorial k# is the product of all primes ≤ k, e.g. 10# = 2 · 3 · 5 · 7.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (k, n_max)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [a, b] for the equation Prime = a + b * k# * n, n=0:n_max; Prime(n_max) must be the optimum minimum.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eValue Range Limits:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [a\u0026lt;150,000 , b\u0026lt;8 ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(13, 13) yields [31385539,14 ]; 31385539 + 14·13#·n (End Prime 36850999)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCommentary:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(13, 16) has a non-minimal end [17, 11387819007325752 ] to give Primes=17 + 11387819007325752·13#·n\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe current June 2013 record for n is 25 via PrimeGrid: 43142746595714191 + 23681770·23#·n\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"isprime\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"isprime\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"isprime\"","","\"","isprime","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fdd46e69d00\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fdd46e69c60\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fdd46e693a0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fdd46e69f80\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fdd46e69ee0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fdd46e69e40\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fdd46e69da0\u003e":"tag:\"isprime\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fdd46e69da0\u003e":"tag:\"isprime\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"isprime\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"isprime\"","","\"","isprime","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fdd46e69d00\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fdd46e69c60\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fdd46e693a0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fdd46e69f80\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fdd46e69ee0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fdd46e69e40\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fdd46e69da0\u003e":"tag:\"isprime\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fdd46e69da0\u003e":"tag:\"isprime\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44305,"difficulty_rating":"easy-medium"},{"id":1688,"difficulty_rating":"unrated"}]}}