{"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":45201,"title":"Check if integer is a prime number","description":"Check if integer i is a prime number. Returns logical true '1' if it is.","description_html":"\u003cp\u003eCheck if integer i is a prime number. Returns logical true '1' if it is.\u003c/p\u003e","function_template":"function b = isPrime(i)\r\n  b = false;\r\nend","test_suite":"%%\r\nassert(isequal(isPrime(2),true))\r\n%%\r\nassert(isequal(isPrime(1),false))\r\n%%\r\nassert(isequal(isPrime(3),true))\r\n%%\r\nassert(isequal(isPrime(11),true))\r\n%%\r\nassert(isequal(isPrime(97),true))\r\n%%\r\nassert(isequal(isPrime(199),true))\r\n%%\r\nassert(isequal(isPrime(65),false))\r\n%%\r\nassert(isequal(isPrime(93),false))\r\n%%\r\nassert(isequal(isPrime(77),false))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":348097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":"2019-11-12T08:49:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-11-11T17:02:13.000Z","updated_at":"2026-02-19T14:28:53.000Z","published_at":"2019-11-12T08:49:31.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eCheck if integer i is a prime number. Returns logical true '1' if it is.\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\"}]}"},{"id":44645,"title":"Prime numbers between a , b.","description":"Find all prime number between a \u0026 b (including a and b).\r\nexample:\r\n\r\na=100\r\n\r\nb=120\r\n\r\ny= [101 103 107 109 113]","description_html":"\u003cp\u003eFind all prime number between a \u0026 b (including a and b).\r\nexample:\u003c/p\u003e\u003cp\u003ea=100\u003c/p\u003e\u003cp\u003eb=120\u003c/p\u003e\u003cp\u003ey= [101 103 107 109 113]\u003c/p\u003e","function_template":"function y = allprimes(a,b)\r\n  y = x;\r\nend","test_suite":"%%\r\na=100;\r\nb=120;\r\ny_correct =  [101 103 107 109 113];\r\nassert(isequal(allprimes(a,b),y_correct))\r\n%%\r\na=140;\r\nb=180;\r\ny_correct =  [149 151 157 163 167 173 179];\r\nassert(isequal(allprimes(a,b),y_correct))\r\n%%\r\na=14;\r\nb=20;\r\ny_correct =  [17 19];\r\nassert(isequal(allprimes(a,b),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":218677,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-18T19:45:06.000Z","updated_at":"2026-04-05T20:58:23.000Z","published_at":"2018-05-18T19:45:06.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eFind all prime number between a \u0026amp; b (including a and b). example:\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\u003ea=100\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\u003eb=120\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\u003ey= [101 103 107 109 113]\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\"}]}"},{"id":1673,"title":"Pandiagonal Prime Magic Square Verification","description":"Verify if an NxN matrix is a Pandiagonal Prime Magic Square.  \r\n\r\nRequired properties:\r\n\r\n  1) N^2 prime values ( No repeats, 1 is a non-prime )\r\n  2) Every row, column, diagonal, anti-diagonal, broken diagonals sum to same value\r\n3) Magic Constant is the sum of a row/column/diagonal\r\n\r\n\r\n*Input:* M  (Matrix NxN)\r\n\r\n*Output:* Magic Constant ( 0 if invalid )\r\n\r\n*Example:*\r\n\r\nm=[7 107 23 103;89 37 73 41;97 17 113 13;47 79 31 83]; Magic is 240\r\n\r\nRows;Columns; Diags 7+37+113+83, 107+73+13+47, 23+41+97+79, 103+89+17+31; \r\n\r\nAnti-Diag 103+73+17+47, 23+37+97+83, 107+89+13+31, 7+41+113+79\r\n\r\n*Related:*\r\n\r\n1) \u003chttp://www.mathworks.com/matlabcentral/cody/problems/1634-kurchan-square-evaluation-function Kurchan Evaluation\u003e has similar array processing\r\n\r\n2) Create Minimum Pandiagonal Prime Magic Squares (6:20) Bonus for 14","description_html":"\u003cp\u003eVerify if an NxN matrix is a Pandiagonal Prime Magic Square.\u003c/p\u003e\u003cp\u003eRequired properties:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1) N^2 prime values ( No repeats, 1 is a non-prime )\r\n2) Every row, column, diagonal, anti-diagonal, broken diagonals sum to same value\r\n3) Magic Constant is the sum of a row/column/diagonal\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e M  (Matrix NxN)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e Magic Constant ( 0 if invalid )\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003em=[7 107 23 103;89 37 73 41;97 17 113 13;47 79 31 83]; Magic is 240\u003c/p\u003e\u003cp\u003eRows;Columns; Diags 7+37+113+83, 107+73+13+47, 23+41+97+79, 103+89+17+31;\u003c/p\u003e\u003cp\u003eAnti-Diag 103+73+17+47, 23+37+97+83, 107+89+13+31, 7+41+113+79\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e1) \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/1634-kurchan-square-evaluation-function\"\u003eKurchan Evaluation\u003c/a\u003e has similar array processing\u003c/p\u003e\u003cp\u003e2) Create Minimum Pandiagonal Prime Magic Squares (6:20) Bonus for 14\u003c/p\u003e","function_template":"function MagicConstant = pandiag(m)\r\n MagicConstant=1;\r\nend\r\n","test_suite":"%%\r\nm=magic(20);\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,0))\r\n%%\r\nm=[41 137 149 19 37 6427 6343 6277 6449 6353 131 211 397 281 431 6421 6329 6197 6271 6199\r\n557 29 367 59 173 5923 6121 6101 6163 6287 643 827 929 947 769 5897 6043 5623 5851 5791\r\n419 571 631 853 919 6053 5801 5783 5573 5387 859 1229 857 1201 1487 5689 5419 5749 5393 5227\r\n1061 1103 1231 661 1093 5323 5381 5231 5189 5273 1847 2293 1499 2281 1867 4789 4243 5059 4889 4787\r\n1249 1277 1423 1889 1997 5051 4951 4931 4241 4373 2239 2309 2069 2731 2377 4481 4483 4597 4159 4273\r\n241 337 607 683 773 6311 6203 5987 5869 5857 151 263 359 421 379 6317 6217 6067 6047 6011\r\n1039 1301 1553 1697 1759 5501 5569 4999 5101 4801 953 503 991 809 1163 5527 5647 5477 5413 5297\r\n1471 2087 2003 1871 2357 5077 4561 4603 4723 4357 1031 1429 1777 1523 1789 5441 4943 4637 4903 4517\r\n2647 3823 2381 3709 3593 3989 2713 4177 3461 3061 1861 2633 2113 2089 2819 4523 3851 4349 3761 3547\r\n3373 3253 3323 3583 3259 3347 3539 3343 3307 3391 2383 2221 2677 2741 2879 3917 4007 3677 3389 3491\r\n6379 6299 6113 6229 6079 89 181 313 239 311 6469 6373 6361 6491 6473 83 167 233 61 157\r\n5867 5683 5581 5563 5741 613 467 887 659 719 5953 6481 6143 6451 6337 587 389 409 347 223\r\n5651 5281 5653 5309 5023 821 1091 761 1117 1283 6091 5939 5879 5657 5591 457 709 727 937 1123\r\n4663 4217 5011 4229 4643 1721 2267 1451 1621 1723 5449 5407 5279 5849 5417 1187 1129 1279 1321 1237\r\n4271 4201 4441 3779 4133 2029 2027 1913 2351 2237 5261 5233 5087 4621 4513 1459 1559 1579 2269 2137\r\n6359 6247 6151 6089 6131 193 293 443 463 499 6269 6173 5903 5827 5737 199 307 523 641 653\r\n5557 6007 5519 5701 5347 983 863 1033 1097 1213 5471 5209 4957 4813 4751 1009 941 1511 1409 1709\r\n5479 5081 4733 4987 4721 1069 1567 1873 1607 1993 5039 4423 4507 4639 4153 1433 1949 1907 1787 2153\r\n4649 3877 4397 4421 3691 1987 2659 2161 2749 2963 3863 2687 4129 2801 2917 2521 3797 2333 3049 3449\r\n4127 4289 3833 3769 3631 2593 2503 2833 3121 3019 3137 3257 3187 2927 3251 3163 2971 3167 3203 3119];\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,65100))\r\n%%\r\nm=[5 73 127 137 53\r\n37 167 17 71 103\r\n83 101 13 67 131\r\n43 31 197 113 11\r\n227 23 41 7 97];\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,395))\r\n%%\r\nm=[191\t89\t397\t409\t43\t157\t311\r\n379\t103\t101\t491\t17\t313\t193\r\n317\t241\t109\t163\t439\t47\t281\r\n223\t383\t227\t107\t541\t37\t79\r\n331\t337\t7\t139\t167\t563\t53\r\n83\t347\t389\t277\t127\t307\t67\r\n73\t97\t367\t11\t263\t173\t613];\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,1597))\r\n%%\r\nm=[191\t89\t397\t409\t43\t157\t311\r\n379\t103\t101\t491\t17\t313\t193\r\n317\t241\t109\t163\t439\t47\t281\r\n223\t383\t227\t107\t541\t37\t79\r\n331\t337\t7\t139\t167\t3\t53\r\n83\t347\t389\t277\t127\t307\t67\r\n73\t97\t367\t11\t263\t173\t613];\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,0))\r\n%%\r\nm=magic(7);\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,0))\r\n\r\n\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":40,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-06-22T04:21:02.000Z","updated_at":"2026-03-02T16:07:10.000Z","published_at":"2013-06-22T06:02:47.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\u003eVerify if an NxN matrix is a Pandiagonal Prime Magic Square.\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\u003eRequired properties:\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[1) N^2 prime values ( No repeats, 1 is a non-prime )\\n2) Every row, column, diagonal, anti-diagonal, broken diagonals sum to same value\\n3) Magic Constant is the sum of a row/column/diagonal]]\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\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 M (Matrix NxN)\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 Magic Constant ( 0 if invalid )\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\u003em=[7 107 23 103;89 37 73 41;97 17 113 13;47 79 31 83]; Magic is 240\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\u003eRows;Columns; Diags 7+37+113+83, 107+73+13+47, 23+41+97+79, 103+89+17+31;\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\u003eAnti-Diag 103+73+17+47, 23+37+97+83, 107+89+13+31, 7+41+113+79\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\u003eRelated:\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\u003e1)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/1634-kurchan-square-evaluation-function\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eKurchan Evaluation\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e has similar array processing\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\u003e2) Create Minimum Pandiagonal Prime Magic Squares (6:20) Bonus for 14\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\"}]}"},{"id":60939,"title":"Frequencies of prime gaps","description":"Problem statement\r\n\r\nGiven two positive integers n and , write a function which computes the frequency of the gap   between two consecutive of the primes in the prime vector going from 2 to n.\r\n\r\nExamples\r\n\r\nFor n = 100 and = 2, your function should return f = 1/3 since one third of the prime gaps between 2 and 97 equal ;\r\nFor n = 1000 and = 6, your function should return f = 44/167;\r\n\r\n\r\nSee also\r\nProblem 60940. Find the first occurence of a given gap between two consecutive prime numbers\r\nPrime numbers properties II","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 414.733px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 207.367px; transform-origin: 408px 207.367px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63.0083px 8px; transform-origin: 63.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eProblem statement\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 21px; text-align: left; transform-origin: 385px 21px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 85.575px 8px; transform-origin: 85.575px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven two positive integers \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 5.83333px 8px; transform-origin: 5.83333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 11.675px 8px; transform-origin: 11.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 180.475px 8px; transform-origin: 180.475px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ewrite a function which computes the frequency of the gap  \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 81.7833px 8px; transform-origin: 81.7833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e between two consecutive of the primes in the prime vector going from \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e2\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 9.71667px 8px; transform-origin: 9.71667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 32.675px 8px; transform-origin: 32.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExamples\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 81.7333px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 40.8667px; transform-origin: 392px 40.8667px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 12.4417px 8px; transform-origin: 12.4417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.4833px 8px; transform-origin: 25.4833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en = 100 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 9.925px 8px; transform-origin: 9.925px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e= 2\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 86.7417px 8px; transform-origin: 86.7417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, your function should return\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.5833px 8px; transform-origin: 21.5833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e f = 1/3\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 133.808px 8px; transform-origin: 133.808px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e since one third of the prime gaps between \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e2\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 9.725px 8px; transform-origin: 9.725px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 97\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.0083px 8px; transform-origin: 21.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e equal \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 55.4333px 8px; transform-origin: 55.4333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor n = 1000 and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 9.925px 8px; transform-origin: 9.925px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e= 6\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 86.7417px 8px; transform-origin: 86.7417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, your function should return\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.8583px 8px; transform-origin: 11.8583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e f = \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 9.725px 8px; transform-origin: 9.725px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e44/\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e167;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.3917px 8px; transform-origin: 28.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eSee also\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/problems/60940-find-the-first-occurence-of-a-given-gap-between-two-consecutive-prime-numbers\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 60940. Find the first occurence of a given gap between two consecutive prime numbers\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/groups/95759\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ePrime numbers properties II\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function f = frequencies_of_prime_gaps(delta, n)\r\n  f = delta*n;\r\nend","test_suite":"%%\r\ndelta = 2;\r\nn = 100;\r\nf_correct = 1/3;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 2;\r\nn = 200;\r\nf_correct = 15/45;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 6;\r\nn = 1000;\r\nf_correct = 44/167;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 4;\r\nn = 200;\r\nf_correct = 13/45;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 24;\r\nn = 10000;\r\nf_correct = 15/1228;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 1;\r\nn = 100;\r\nf_correct = 1/24;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 3;\r\nn = 100;\r\nf_correct = 0;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%% Forbidden functions\r\nfiletext = fileread('frequencies_of_prime_gaps.m');\r\nillegal = contains(filetext, 'regexp') || contains(filetext, 'str2num') || contains(filetext, 'assignin') || contains(filetext, 'echo')\r\nassert(~illegal);","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":149128,"edited_by":149128,"edited_at":"2025-07-26T06:48:50.000Z","deleted_by":null,"deleted_at":null,"solvers_count":27,"test_suite_updated_at":"2025-07-09T05:56:16.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2025-06-24T10:21:21.000Z","updated_at":"2026-03-16T13:25:01.000Z","published_at":"2025-06-24T11:07:25.000Z","restored_at":null,"restored_by":null,"spam":null,"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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eProblem statement\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\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\u003eGiven two positive integers \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ewrite a function which computes the frequency of the gap  \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e between two consecutive of the primes in the prime vector going from \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en = 100 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e= 2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, your function should return\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = 1/3\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e since one third of the prime gaps between \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 97\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e equal \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor n = 1000 and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e= 6\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, your function should return\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e44/\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e167;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSee also\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/problems/60940-find-the-first-occurence-of-a-given-gap-between-two-consecutive-prime-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 60940. Find the first occurence of a given gap between two consecutive prime numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/groups/95759\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePrime numbers properties II\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":42317,"title":"De-primed","description":"Write a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.","description_html":"\u003cp\u003eWrite a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.\u003c/p\u003e","function_template":"function [M] = de_primed(M)\r\n\r\nM = M;\r\n\r\nend\r\n","test_suite":"%%\r\nM = 1:10;\r\nM_corr = [2,4,6,4,10,6,14,8,9,10];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\nM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\nM_corr = [4 M(2:end)];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 10:10:100;\r\nM_corr = M;\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 3:3:100;\r\nM_corr = [6,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\nM_corr = 2*M;\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = magic(6);\r\nM_corr = [35, 2, 6,26,38,24;\r\n           6,32,14,21,46,25;\r\n          62, 9, 4,22,27,20;\r\n           8,28,33,34,10,15;\r\n          30,10,34,12,14,16;\r\n           4,36,58,26,18,22];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\n\tcase 2\r\n\t\tM = eye(4);\r\n\t\tM_corr = 2*M;\r\n\tcase 3\r\n\t\tM = 10:10:100;\r\n\t\tM_corr = M;\r\n\tcase 4\r\n\t\tM = magic(6);\r\n\t\tM_corr = [35, 2, 6,26,38,24;\r\n           6,32,14,21,46,25;\r\n          62, 9, 4,22,27,20;\r\n           8,28,33,34,10,15;\r\n          30,10,34,12,14,16;\r\n           4,36,58,26,18,22];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 3:3:100;\r\n\t\tM_corr = [6,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99];\r\n\tcase 2\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\n\tcase 3\r\n\t\tM = eye(4);\r\n\t\tM_corr = 2*M;\r\n\tcase 4\r\n\t\tM = 20:3:50;\r\n\t\tM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 20:3:50;\r\n\t\tM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\n\tcase 2\r\n\t\tM = 10:10:100;\r\n\t\tM_corr = M;\r\n\tcase 3\r\n\t\tM = 2:2:100;\r\n\t\tM_corr = [4 M(2:end)];\r\n\tcase 4\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":171,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-17T01:45:02.000Z","updated_at":"2026-03-11T18:31:28.000Z","published_at":"2015-05-17T01:45:02.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eWrite a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.\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\"}]}"},{"id":44699,"title":"Prime Product","description":"My professor has given a sequence of N numbers as a1, a2, ..., aN and asked me to find the smallest possible value of ai * aj such that it is a prime number, where 1 \u003c= i \u003c j \u003c= N.\r\n\r\nIf it's possible to find any value of ai * aj such that it is a prime number, then print the smallest value of such ai * aj, otherwise print -1.\r\n\r\n  x=[1 2 3]\r\ny = 2\r\n\r\n\r\n  x=[5 5 5 2]\r\ny = -1\r\n","description_html":"\u003cp\u003eMy professor has given a sequence of N numbers as a1, a2, ..., aN and asked me to find the smallest possible value of ai * aj such that it is a prime number, where 1 \u0026lt;= i \u0026lt; j \u0026lt;= N.\u003c/p\u003e\u003cp\u003eIf it's possible to find any value of ai * aj such that it is a prime number, then print the smallest value of such ai * aj, otherwise print -1.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex=[1 2 3]\r\ny = 2\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003ex=[5 5 5 2]\r\ny = -1\r\n\u003c/pre\u003e","function_template":"function y = prime_product(x)\r\n  % my first problem I created\r\nend","test_suite":"%%\r\nx = [1 2 3];\r\ny_correct = 2;\r\nassert(isequal(prime_product(x),y_correct))\r\n\r\n%%\r\nx = [5 2 5 2];\r\ny_correct = -1;\r\nassert(isequal(prime_product(x),y_correct))\r\n\r\n%%\r\nx = [1 63];\r\ny_correct = -1;\r\nassert(isequal(prime_product(x),y_correct))\r\n\r\n%% \r\nx = [ 3 6 234 1 623 234 ];\r\ny_correct = 3;\r\nassert(isequal(prime_product(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":195572,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":34,"test_suite_updated_at":"2018-07-30T18:29:12.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-07-18T20:13:31.000Z","updated_at":"2025-12-09T15:21:32.000Z","published_at":"2018-07-18T20:40:31.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\u003eMy professor has given a sequence of N numbers as a1, a2, ..., aN and asked me to find the smallest possible value of ai * aj such that it is a prime number, where 1 \u0026lt;= i \u0026lt; j \u0026lt;= 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\u003eIf it's possible to find any value of ai * aj such that it is a prime number, then print the smallest value of such ai * aj, otherwise print -1.\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[x=[1 2 3]\\ny = 2\\n\\nx=[5 5 5 2]\\ny = -1]]\u003e\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\"}]}"},{"id":54119,"title":"Create the Ulam spiral","description":"Have you ever seen this wonderful spiral ? The Ulam Spiral is arranging prime numbers in a clockwise spiral starting in 0.\r\nGiven an n by n matrix of 0s, fill it with 1 if the number is prime, in that order : \r\n[7 8 9;\r\n 6 1 2;\r\n 5 4 3;]\r\n\r\nWhich will give you :\r\n[1 0 0;\r\n 0 0 1;\r\n 1 0 1;]\r\n\r\nAs you experiment, look out for the strange patterns that emerge!\r\n","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 381px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 190.5px; transform-origin: 407px 190.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 379px 8px; transform-origin: 379px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHave you ever seen this wonderful spiral ? The Ulam Spiral is arranging prime numbers in a clockwise spiral starting in 0.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 242.5px 8px; transform-origin: 242.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven an n by n matrix of 0s, fill it with 1 if the number is prime, in that order : \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e[7 8 9;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e 6 1 2;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22px 8px; transform-origin: 22px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e 5 4 3;]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63px 8px; transform-origin: 63px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhich will give you :\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e[1 0 0;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e 0 0 1;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22px 8px; transform-origin: 22px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e 1 0 1;]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 206px 8px; transform-origin: 206px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAs you experiment, look out for the strange patterns that emerge!\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y= ulam_spiral(n)\r\n    y=zeros(n);\r\nend\r\n","test_suite":"%%\r\nx = 3;\r\ny_correct = [1 0 0; 0 0 1; 1 0 1];\r\nassert(isequal(ulam_spiral(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct =[0     0     1     0     0;     0     1     0     0     0;     1     0     0     1     1;     0     1     0     1     0;     1     0     0     0     1];\r\nassert(isequal(ulam_spiral(x),y_correct))\r\n%%\r\nx = 1;\r\nassert(isequal(ulam_spiral(x),~x))\r\n%%\r\nx = 2;\r\ny_correct = [0 1; 0 1];\r\nassert(isequal(ulam_spiral(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":2001505,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2022-03-05T06:01:52.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-03-04T19:34:20.000Z","updated_at":"2022-03-05T06:01:52.000Z","published_at":"2022-03-04T19:34:20.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\u003eHave you ever seen this wonderful spiral ? The Ulam Spiral is arranging prime numbers in a clockwise spiral starting in 0.\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\u003eGiven an n by n matrix of 0s, fill it with 1 if the number is prime, in that order : \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\u003e[7 8 9;\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\u003e 6 1 2;\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\u003e 5 4 3;]\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\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 will give you :\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\u003e[1 0 0;\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\u003e 0 0 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\u003e 1 0 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\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\u003eAs you experiment, look out for the strange patterns that emerge!\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\u003e\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":45794,"title":"*Prime number check 2 (in construction)","description":"Another way to see if a number is prime is to count the number of factors. For example,\r\n\r\n  the number 4 has 2 factors, [ 2 4 ]\r\n  the number 16 has 4 factors, [ 2 4 8 16 ]\r\n  the number 7 has 1 factor, [ 7 ]\r\n\r\nThus, if a number has only one factor, it is prime. We ignore the factor 1 as it is trivial. \r\n\r\nYour function should create a vector containing all the factors of any number x.","description_html":"\u003cp\u003eAnother way to see if a number is prime is to count the number of factors. For example,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ethe number 4 has 2 factors, [ 2 4 ]\r\nthe number 16 has 4 factors, [ 2 4 8 16 ]\r\nthe number 7 has 1 factor, [ 7 ]\r\n\u003c/pre\u003e\u003cp\u003eThus, if a number has only one factor, it is prime. We ignore the factor 1 as it is trivial.\u003c/p\u003e\u003cp\u003eYour function should create a vector containing all the factors of any number x.\u003c/p\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 16;\r\ny_correct = [ 2 4 8 16 ];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 23;\r\ny_correct = [ 23 ];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 100;\r\ny_correct = [ 2 4 5 10 20 25 50 100 ];\r\nassert(isequal(your_fcn_name(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":428668,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-06-07T20:00:06.000Z","updated_at":"2025-08-03T17:44:27.000Z","published_at":"2020-06-07T20:00:06.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\u003eAnother way to see if a number is prime is to count the number of factors. For example,\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[the number 4 has 2 factors, [ 2 4 ]\\nthe number 16 has 4 factors, [ 2 4 8 16 ]\\nthe number 7 has 1 factor, [ 7 ]]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThus, if a number has only one factor, it is prime. We ignore the factor 1 as it is trivial.\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\u003eYour function should create a vector containing all the factors of any number x.\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\"}]}"},{"id":45342,"title":"Sieve of Eratosthenes","description":"Find the nth lucky prime number.\r\n\r\n\u003chttps://planetmath.org/luckyprime\u003e\r\n\r\ncan u find a way for large n?","description_html":"\u003cp\u003eFind the nth lucky prime number.\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://planetmath.org/luckyprime\"\u003ehttps://planetmath.org/luckyprime\u003c/a\u003e\u003c/p\u003e\u003cp\u003ecan u find a way for large n?\u003c/p\u003e","function_template":"function y = lucky_prime(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(lucky_prime(4),31))\r\n%%\r\nassert(isequal(lucky_prime(10),127))\r\n%%\r\nassert(isequal(lucky_prime(20),349))\r\n%%\r\nassert(isequal(lucky_prime(27),541))\r\n%%\r\nassert(isequal(lucky_prime(39),823))\r\n%%\r\nassert(isequal(lucky_prime(50),1123))\r\n%%\r\nassert(isequal(lucky_prime(60),1579))\r\n%%\r\nassert(isequal(lucky_prime(70),1987))\r\n%%\r\nassert(isequal(lucky_prime(90),2971))\r\n%%\r\nassert(isequal(lucky_prime(80),2473))\r\n%%\r\nassert(isequal(lucky_prime(200),9403))\r\n%%\r\nassert(isequal(lucky_prime(260),12799))\r\n%%\r\nassert(isequal(lucky_prime(440),25237))\r\n%%\r\nassert(isequal(lucky_prime(600),38461))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":"2020-04-02T00:55:41.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2020-02-18T19:05:49.000Z","updated_at":"2026-01-19T18:26:06.000Z","published_at":"2020-02-18T19:39:25.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\u003eFind the nth lucky prime number.\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:hyperlink w:docLocation=\\\"https://planetmath.org/luckyprime\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://planetmath.org/luckyprime\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\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\u003ecan u find a way for large 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\"}]}"},{"id":3016,"title":"Twin Primes","description":"Twin primes are pairs of primes that are immediately next to each other (difference of two). The lesser of twin primes are 3, 5, 11, 17, 29, ... ( \u003chttp://oeis.org/A001359 ref.\u003e ). The greater of twin primes are 5, 7, 13, 19, 31, ... ( \u003chttp://oeis.org/A006512 ref.\u003e ). Therefore, the first five twin primes are [3,5] [5,7] [11,13] [17,19] [29,31].\r\n\r\nFor a given index range n, return the twin primes corresponding to that range as a two-row column array.","description_html":"\u003cp\u003eTwin primes are pairs of primes that are immediately next to each other (difference of two). The lesser of twin primes are 3, 5, 11, 17, 29, ... ( \u003ca href = \"http://oeis.org/A001359\"\u003eref.\u003c/a\u003e ). The greater of twin primes are 5, 7, 13, 19, 31, ... ( \u003ca href = \"http://oeis.org/A006512\"\u003eref.\u003c/a\u003e ). Therefore, the first five twin primes are [3,5] [5,7] [11,13] [17,19] [29,31].\u003c/p\u003e\u003cp\u003eFor a given index range n, return the twin primes corresponding to that range as a two-row column array.\u003c/p\u003e","function_template":"function [twins] = twin_primes(n)\r\n\r\ntwins = n;\r\n\r\nend","test_suite":"%%\r\nn = 1:5;\r\ntwins_corr = [3, 5, 11, 17, 29; 5, 7, 13, 19, 31];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 1:10;\r\ntwins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 1:25;\r\ntwins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 1:51;\r\ntwins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641, 659, 809, 821, 827, 857, 881, 1019, 1031, 1049, 1061, 1091, 1151, 1229, 1277, 1289, 1301, 1319, 1427, 1451, 1481, 1487, 1607; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523, 571, 601, 619, 643, 661, 811, 823, 829, 859, 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231, 1279, 1291, 1303, 1321, 1429, 1453, 1483, 1489, 1609];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 10:29;\r\ntwins_corr = [107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641; 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523, 571, 601, 619, 643];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 2:8;\r\ntwins_corr = [5, 11, 17, 29, 41, 59, 71; 7, 13, 19, 31, 43, 61, 73];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 35:42;\r\ntwins_corr = [881, 1019, 1031, 1049, 1061, 1091, 1151, 1229; 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 34:47;\r\ntwins_corr = [857, 881, 1019, 1031, 1049, 1061, 1091, 1151, 1229, 1277, 1289, 1301, 1319, 1427; 859, 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231, 1279, 1291, 1303, 1321, 1429];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 9:-1:4;\r\ntwins_corr = [101, 71, 59, 41, 29, 17; 103, 73, 61, 43, 31, 19];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":98,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":30,"created_at":"2015-02-14T03:03:50.000Z","updated_at":"2026-03-16T14:18:09.000Z","published_at":"2015-02-14T03:03:50.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\u003eTwin primes are pairs of primes that are immediately next to each other (difference of two). The lesser of twin primes are 3, 5, 11, 17, 29, ... (\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://oeis.org/A001359\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eref.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e ). The greater of twin primes are 5, 7, 13, 19, 31, ... (\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://oeis.org/A006512\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eref.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e ). Therefore, the first five twin primes are [3,5] [5,7] [11,13] [17,19] [29,31].\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\u003eFor a given index range n, return the twin primes corresponding to that range as a two-row column array.\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\"}]}"},{"id":42509,"title":"Divisible by n, Truncated-number Divisors","description":"Some divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\r\n\r\n* 25: The last two digits must be divisible by 25.\r\n* 32: The last five digits must be divisible by 32.\r\n* 50: The last two digits must be 00 or 50.\r\n* 64: The last six digits must be divisible by 64.\r\n* 75: The number must be divisible by 3 (can be done by a \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3 simple sum\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25). \r\n* 100: The last two digits must be 00.\r\n* 125: The last three digits must be divisible by 125.\r\n* 128: The last seven digits must be divisible by 128.\r\n* 256: The last eight digits must be divisible by 256.\r\n* 512: The last nine digits must be divisible by 512.\r\n\r\nThe only restriction that remains is Java.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200 Divisible by n, prime divisors from 20 to 200\u003e. Next problem \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors Divisible by n, Composite Divisors\u003e.","description_html":"\u003cp\u003eSome divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\u003c/p\u003e\u003cul\u003e\u003cli\u003e25: The last two digits must be divisible by 25.\u003c/li\u003e\u003cli\u003e32: The last five digits must be divisible by 32.\u003c/li\u003e\u003cli\u003e50: The last two digits must be 00 or 50.\u003c/li\u003e\u003cli\u003e64: The last six digits must be divisible by 64.\u003c/li\u003e\u003cli\u003e75: The number must be divisible by 3 (can be done by a \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3\"\u003esimple sum\u003c/a\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25).\u003c/li\u003e\u003cli\u003e100: The last two digits must be 00.\u003c/li\u003e\u003cli\u003e125: The last three digits must be divisible by 125.\u003c/li\u003e\u003cli\u003e128: The last seven digits must be divisible by 128.\u003c/li\u003e\u003cli\u003e256: The last eight digits must be divisible by 256.\u003c/li\u003e\u003cli\u003e512: The last nine digits must be divisible by 512.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe only restriction that remains is Java.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\"\u003eDivisible by n, prime divisors from 20 to 200\u003c/a\u003e. Next problem \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors\"\u003eDivisible by n, Composite Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = truncated_number_divisors(n,n_str)\r\n\r\ntf = 1;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('truncated_number_divisors.m');\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 25;\r\nn_str = '123456789025';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 25;\r\nn_str = '1234567890250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 25;\r\nn_str = '1234567890250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 32;\r\nn_str = '213546116579874651316984601654958847098406516051320150408460840649084790870510201378465465046760406541654604601561065140637860373703970644065166540616510650165409684098049804165016510320540540645106056501650165709804650860466840650156106165028224';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 32;\r\nn_str = '213546116579874651316984601654958847098406516051320150408460840649084790870510201378465465046760406541654604601561065140637860373703970644065166540616510650165409684098049804165016510320540540645106056501650165709804650860466840650156106165028227';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '15668045014654987098045406540500';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '50440984098480149540561065106510516501615001';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '50440984098480149540561065106510516501615001897241387234587503198417059813645097867234985672307485679813709582304957234897659832746098514949188412929894824924949334949777378994191995216173718811313515141418186186382171646871681436817897678350';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404996';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489216';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489217';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 75;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499175';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 75;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499275';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992750';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992700';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499200';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499200125';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489216';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111114892375';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 128;\r\nn_str = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111148923751048576';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 128;\r\nn_str = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111148923751048578';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 256;\r\nn_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678904049917516777216';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 256;\r\nn_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678904049917516777210';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000134217728';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000536870912';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000536870914';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-17T21:32:54.000Z","updated_at":"2026-01-11T10:42:54.000Z","published_at":"2015-08-17T21:32:54.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\u003eSome divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e25: The last two digits must be divisible by 25.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e32: The last five digits must be divisible by 32.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e50: The last two digits must be 00 or 50.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e64: The last six digits must be divisible by 64.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e75: The number must be divisible by 3 (can be done by a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esimple sum\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e100: The last two digits must be 00.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e125: The last three digits must be divisible by 125.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e128: The last seven digits must be divisible by 128.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e256: The last eight digits must be divisible by 256.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e512: The last nine digits must be divisible by 512.\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 only restriction that remains is Java.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors from 20 to 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Composite Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":60941,"title":"Prime numbers which are the difference of two consecutive cubes","description":"Problem statement\r\n\r\nGiven a positive integer n greater than 2, find the prime numbers less or equal to n and which are the difference of the cubes of two consecutive integers and store them in ascending order in a row vector u. Also, compute the frequency / ratio f of those numbers compare to all the prime numbers less or equal to n.\r\n\r\nExamples\r\n\r\nIf n = 100, then u = [7, 19, 37, 61], and f = 4/25, since 7 = 2^3 - 1^3, 19 = 3^3 - 2^3, 37 = 4^3 - 3^3, 61 = 5^3 - 4^3, and there are 25 prime numbers less or equal to 100;\r\nIf n = 400, then u = [7, 19, 37, 61, 127, 271, 331, 397], and f = 8/78, since 127 = 7^3 - 6^3, 271 = 10^3 - 9^3, 331 = 11^3 - 10^3, 397 = 12^3 - 11^3, and there are 78 prime numbers less or equal to 400;\r\nTips\r\n\r\n\r\n\r\nForbidden functions\r\n\r\nregexpr\r\nstr2num\r\nassignin\r\n\r\nSee also\r\nPrime numbers properties II","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 668.033px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 334.017px; transform-origin: 408px 334.017px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63.0083px 8px; transform-origin: 63.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eProblem statement\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 31.5px; text-align: left; transform-origin: 385px 31.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 75.075px 8px; transform-origin: 75.075px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a positive integer \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 5.83333px 8px; transform-origin: 5.83333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 37.7333px 8px; transform-origin: 37.7333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003egreater than\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 9.71667px 8px; transform-origin: 9.71667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 2, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 122.917px 8px; transform-origin: 122.917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003efind the prime numbers less or equal to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 129.833px 8px; transform-origin: 129.833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and which are the difference of the cubes of two consecutive integers and store them in ascending order in a row vector \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eu\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 113.95px 8px; transform-origin: 113.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Also, compute the frequency / ratio \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ef\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 9.71667px 8px; transform-origin: 9.71667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e of those numbers compare to all the prime numbers less or equal to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 32.675px 8px; transform-origin: 32.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExamples\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 81.7333px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 40.8667px; transform-origin: 392px 40.8667px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 6.21667px 8px; transform-origin: 6.21667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eIf \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 27.8083px 8px; transform-origin: 27.8083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003en = 100, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 14.775px 8px; transform-origin: 14.775px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ethen\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 61.6333px 8px; transform-origin: 61.6333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e u = [7, 19, 37, 61], \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 12.4417px 8px; transform-origin: 12.4417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.8667px 8px; transform-origin: 25.8667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e f = 4/25\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 16.3417px 8px; transform-origin: 16.3417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 190.017px 8px; transform-origin: 190.017px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 7 = 2^3 - 1^3, 19 = 3^3 - 2^3, 37 = 4^3 - 3^3, 61 = 5^3 - 4^3, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 41.625px 8px; transform-origin: 41.625px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand there are\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.6667px 8px; transform-origin: 11.6667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 25 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 96.0833px 8px; transform-origin: 96.0833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eprime numbers less or equal to\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 100;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 6.21667px 8px; transform-origin: 6.21667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eIf \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 27.8083px 8px; transform-origin: 27.8083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003en = 400, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 14.775px 8px; transform-origin: 14.775px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ethen\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 123.867px 8px; transform-origin: 123.867px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e u = [7, 19, 37, 61, 127, 271, 331, 397], \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 12.4417px 8px; transform-origin: 12.4417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.8667px 8px; transform-origin: 25.8667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e f = 8/78\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 16.3417px 8px; transform-origin: 16.3417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 129.25px 8px; transform-origin: 129.25px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 127 = 7^3 - 6^3, 271 = 10^3 - 9^3, 331 = 11^3 - 10^3, 397 = 12^3 - 11^3, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 41.625px 8px; transform-origin: 41.625px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand there are\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.6667px 8px; transform-origin: 11.6667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 78 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 96.0833px 8px; transform-origin: 96.0833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eprime numbers less or equal to\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 400;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14.2583px 8px; transform-origin: 14.2583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eTips\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWAAAAAnCAYAAAAxS5IsAAAKO0lEQVR4Xu2dW8h2QxTHfffkdMUFwgXlVI4RF3IokSRn6S1yuJAUiiQXQijJhUPoS5JDLkSKRBE5JIeICwoXXBFxz/rVs7JMe78zs/fs2bP3t3atvsOznzn8Z81/rVlrZp4du/njCDgCjoAjMAsCO2ap1St1BBwBR8AR2M0J2JXAEXAEHIGZEHACngl4r9YRcAQcASdg1wFHwBFwBGZCwAm4PvD7SJWPiZwjsrvI3yLXiLxYvymT13i81HCPyFmbmr6TP68S+XTympdbgWJ28kY/fpU/b16pfix3lAq1PJeAIY/rRO4rVP8airleOvGSyO+JnflW3vtK5GmRg0Ue3Ey0s+XPtxLLWMJrh0gj3xd5TuRtkTNEbt00PFfvltDfEm2EfF8VeVTkM5ELRa7dFIye3FaiEi+jHQRyJgLk+4bIjSLuwfw3hkwaJkwKLpA1pGsnEv+HR/ykCMZtLQ8ePUbGGhX+72KRS0XW6PGPHbs3pYBnAmxul3/fK8JKaY+xFfj320IglYAh3w9EfPnYPX7quZwfMU6894OI9ZZZnjPx7hBZ08qCfoUe/QPyf3jBJ0RwamuW1GvNR1IVoSmrH8y93zZN2Df4rF7LvKZJEEglYBTjPZFdaQnEEhrPYy8RwgOxB8J5ROSUzEkCKZ034Hux9rT4OXr0k8glLTaup02M69Uip4rsJ4In+qHInSK1VoL/SF3Ego/I1K2aMLeAU83+blcXq9q7RGIOWdI+YAjiSpH9W+ndxO1Q4mWpzIMXl0LAvIsn+6NIaigBpd2ZMlAT97lG8SylWUHlGqgabeurQ8NDkN/PIgeIQML61AiloI/fZ+phbcxawKl2n7vqU+JVHYmu9GIeMMsfPBaWjY+30MOJ2wBJHCOC16uZ+xwC1skSS6gRirhFREmebh0qQnhibQ/eLln8Ezcdg8yWYMxp98MixPdtaAi9eEWEHSw1+sKkJgF3ukgtjztHB1vBKafNpd9lPrOTiefyjW7w99EE3Kr3i1JuiZQOi0CgSoIs+3hyCJj3WWb/KZLiNWvY4jB5/2ORk0prRkPlKZFAXEvI6LNbpS/noYmxpEk2cgx+ke+zk6RU+O8JKetoEYxLiURoKzilwsz85LnCzPXU7/a9Z3lD8xxJuhHzgP+SUp4XSV1Sj+1I6ve1k7nkmFo+7w0lYF2OpXq0rDK+FmHZEhuPnPa3+C6ewicirRsbDOOxIn1JUU2cEg+e0jNFzw8UuUEkdZtjbNwhIFYjJZK+reAU67P9XOd11DvNKdS8W4yAWVq8IFIjzpXb15YJWMMQOQqu/dkVstwQwJ4ih+cOekPv69zgYMlU/dDQTbgrYiwMJQk41pYaOMXaEH6+GAJmqcIm8BZJoWUCZsBZOZApTwlD8L7vhMidRvO+z9IdYpzqBKPuLS+5TFbEahLw1DgN0YLFELAOVGxZjLJwuIAl22kiZIq3RAgPhMduOTFWYgtS6wQMduCQmmzi/S9FWgv14M0jnGIjbkifXhPReKTmCAif4A3GdjhoUncq4hoyIXO/o5nuvuPB9PG4zXwgoUsIgUfj++j/3SLE/btCGLqnnG1vYVIWQhsbjqhFwFPjlDtu+v5iCBgv7hujOH0dJiFxkIgemdT9ikzcd0Q4PXfURuEoI7ZDIAXYJRAwcbbQeDGBmFh28qKoN4mc2zHhUrCY8h3IAsPKpCd5xkPsDGLgYA7JRkR3jNjkGskjtm7ZE4Ka9MklEZ00Y/o6Nl8AsRITVj3HmejqBwR6kQh7uyFZHg1H6fhjxLQcGw9nznwhwrwjwWwfnJsSRnpqAq6B0xg9WAwB09CcZIl2DMV8SIQz7VsiKH5WYDoB3dYJWNsXJuIwVkxG3cLERPxcJOcuiQR4ir+ikxYvF0PxusizIhCSJqQs0fB3PXbM39EjyAODPCTzPicBh/vCLbh4sHi5XdsHrc6jBxzq4VHSDpO8etpUSbtrEEskjqYi4Fo4jVXuVRKwnYQk7e7eiE42nYwpy9QUgJdCwCW8/RQ8pn5HlRYPlyX1HyIaLtFdH7QhdefH1O2dqnz1bu2KoC8Rp0SH8dkpsiWiCTVN1Coh19xjPxUBW8xbxmmVBKyEqMc0fzQTlIFhryCWPTUGbAl9zGTK2YkQ1jN0GxrlKB5TEHAJbHKW47Y+xg8Ctpl5TdaWMq5jxrvWdzVUYMMy4SEJqz9HSsNsTFd3B0xhtKznPQaPEt72HDipgRnT9zEXH2Wt9rdLsOWEIJRg6TQW305Qa+1Tt7SVIBnaMhcBT7mDpAQ2OQSsfQHPriU3sV6ScGu7zS02ga3nH+qZJVjKCfXerghLb2NriYDpe22cVkPAmkSJnc6ytzUBeGg5dQCYvHhPJTaUtx6CSN1BEpvkLXxujWtINNa4TuHtt9D/vjZYvQ9xsUary9ip0ZrjRGCNEITFrDWcFhOCSCURa+G6vCC19jkJvdjEWwIBL/2wAWNgCTZc2VjvpqRx7Rr7OZNw2+mitis0PkqwXSuGuY1WbQIGv5ZwWgwB92XyQ4W02e6uuBHb2YiVjQkHhHW2TsAMcmq8O2Zs5vx8u+Uj7eL2N0IiOSGNIf1pkYDVswuvibQE24WL3iMx1/WStQm4NZwWQ8B6bj8Wt1WC7fJwtQwbmmB5NvbAQcsErH0mU14zuz2E2GLfUYLt83BD4wq5YHjWeKtbiJUapzCMYC/q6QrLhEYLA7a3yJDtebHx6/q8NgG3htNiCJjBYynF73r1nV6zBNvl4YYZcn56h+stx97s1DIB0zbIt1S8e8gkK/UdJdguTy7M5J8plV4gcplIiTh/qT4MKUePAnPIpOvidT5nT3PXQSUl2C4P18ZD0RF+94391DUP4ZQk4CXitCgCjpGJtfZde0B1sHV7GvtHc09BdU2gqQnY7jTIvXAlZrSGEMIc37HGtcubt9l2vF5OO9YkkikxsXpNPfSP37fj4WQgp/s4RMN7obFRo9UVgrJ6hVFje9qWSPjTTVP2rSQBLxGnqQnY7sKIRQ+i1x/GLmS3J6S67gFQLwkCxvu9v0NhhyjbVATMcgkvTo/WatvwZriT9WWR7S7F5ntc1t13OmpIX+f6TniSKwwr2D2ekA0roLWEHsI7TBgD/VUMTnj2hVkswfaFoHRXCSE7framJvnSj5IEvEScpiBg5gKreo6f219MAW90hePlnVebxi7aoQBI9CmRlpbUEOWWSImz8SUJjsllL6spWbaX5QiUQEAvZN8phS09RzEEDwwQT8qvmA8pP+s7KQRMgZogKHGTWVYDF/QyHiMXpsT2TS+oS95UR8ARmBKBVAKmDViOXdVqxsaApeeQX0SOleufOwKOwIoRyCFg9YTf3UWXLn1qoJlge/x6xSrjXXMEHIFSCOQSMPUShqi1Z7FUP6csx/GYEl0v2xFYMQJDCHjFcHjXHAFHwBGoh4ATcD2svSZHwBFwBP6HgBOwK4Qj4Ag4AjMh4AQ8E/BerSPgCDgCTsCuA46AI+AIzITAv+XNK1XoyvVEAAAAAElFTkSuQmCC\" width=\"176\" height=\"19.5\" style=\"width: 176px; height: 19.5px;\"\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 67.6417px 8px; transform-origin: 67.6417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eForbidden functions\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 30.65px; transform-origin: 392px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 23.7333px 8px; transform-origin: 23.7333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eregexpr\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.2833px 8px; transform-origin: 25.2833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003estr2num\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.6833px 8px; transform-origin: 25.6833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eassignin\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.3917px 8px; transform-origin: 28.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eSee also\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/groups/95759\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ePrime numbers properties II\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [u, f] = cube_delta_primes(n)\r\n  \r\n    u = n;\r\n    f = 1;\r\n\r\nend","test_suite":"%%\r\nn = 100;\r\nu_correct = [7, 19, 37, 61];\r\nf_correct = 4/25;\r\n[u,f] = cube_delta_primes(n);\r\nassert(isequal([u,f],[u_correct,f_correct]));\r\n\r\n%%\r\nn = 400;\r\nu_correct = [7, 19, 37, 61, 127, 271, 331, 397];\r\nf_correct = 8/78;\r\n[u,f] = cube_delta_primes(n);\r\nassert(isequal([u,f],[u_correct,f_correct]));\r\n\r\n%% Forbidden functions\r\nfiletext = fileread('cube_delta_primes.m');\r\nillegal = contains(filetext, 'regexp') || contains(filetext, 'str2num') || contains(filetext, 'assignin') || contains(filetext, 'echo')\r\nassert(~illegal);","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":149128,"edited_by":149128,"edited_at":"2025-07-26T06:46:51.000Z","deleted_by":null,"deleted_at":null,"solvers_count":30,"test_suite_updated_at":"2025-07-09T05:55:53.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2025-06-26T11:57:42.000Z","updated_at":"2026-03-30T01:16:24.000Z","published_at":"2025-06-26T12:34:41.000Z","restored_at":null,"restored_by":null,"spam":null,"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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eProblem statement\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\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\u003eGiven a positive integer \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003egreater than\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 2, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003efind the prime numbers less or equal to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and which are the difference of the cubes of two consecutive integers and store them in ascending order in a row vector \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eu\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Also, compute the frequency / ratio \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of those numbers compare to all the prime numbers less or equal to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eIf \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en = 100, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e u = [7, 19, 37, 61], \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = 4/25\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003esince\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 7 = 2^3 - 1^3, 19 = 3^3 - 2^3, 37 = 4^3 - 3^3, 61 = 5^3 - 4^3, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand there are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 25 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eprime numbers less or equal to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 100;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eIf \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en = 400, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e u = [7, 19, 37, 61, 127, 271, 331, 397], \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = 8/78\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003esince\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 127 = 7^3 - 6^3, 271 = 10^3 - 9^3, 331 = 11^3 - 10^3, 397 = 12^3 - 11^3, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand there are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 78 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eprime numbers less or equal to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 400;\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTips\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"true\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e(n+1)^3 - n^3 = 3n^2 + 3n + 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eForbidden functions\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexpr\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estr2num\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassignin\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSee also\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/groups/95759\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePrime numbers properties II\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":896,"title":"Sophie Germain prime","description":"In number theory, a prime number p is a *Sophie Germain prime* if 2p + 1 is also prime. For example, 23 is a Sophie Germain prime because it is a prime and 2 × 23 + 1 = 47, and 47 is also a prime number. These numbers are named after French mathematician Marie-Sophie Germain.\r\n\r\nSee \u003chttp://en.wikipedia.org/wiki/Sophie_Germain_prime Sophie Germain prime\u003e article on Wikipedia.\r\n\r\n\r\nIn this Problem , the input is a number and you must return true or false if this number is a Sophie Germain prime.","description_html":"\u003cp\u003eIn number theory, a prime number p is a \u003cb\u003eSophie Germain prime\u003c/b\u003e if 2p + 1 is also prime. For example, 23 is a Sophie Germain prime because it is a prime and 2 × 23 + 1 = 47, and 47 is also a prime number. These numbers are named after French mathematician Marie-Sophie Germain.\u003c/p\u003e\u003cp\u003eSee \u003ca href=\"http://en.wikipedia.org/wiki/Sophie_Germain_prime\"\u003eSophie Germain prime\u003c/a\u003e article on Wikipedia.\u003c/p\u003e\u003cp\u003eIn this Problem , the input is a number and you must return true or false if this number is a Sophie Germain prime.\u003c/p\u003e","function_template":"function tf = your_fcn_name(x)\r\n  tf = true;\r\nend","test_suite":"%%\r\np = 233;\r\ny_correct = true;\r\nassert(isequal(your_fcn_name(p),y_correct))\r\n\r\n%%\r\np = 23;\r\ny_correct14 = true;\r\nassert(isequal(your_fcn_name(p),y_correct14))\r\n\r\n%%\r\np = 22;\r\ny_correct14 = false;\r\nassert(isequal(your_fcn_name(p),y_correct14))\r\n\r\n%% \r\np = 1 % p must also be a prime number !!\r\ny_correct1t = false;\r\nassert(isequal(your_fcn_name(p),y_correct1t))\r\n\r\n%% \r\np = 14 % p must also be a prime number !!\r\ncorrect1t = false;\r\nassert(isequal(your_fcn_name(p),correct1t))\r\n\r\n%% \r\np = 29 \r\ncorrect1tp = true;\r\nassert(isequal(your_fcn_name(p),correct1tp))\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":2,"created_by":639,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1066,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":44,"created_at":"2012-08-10T13:04:11.000Z","updated_at":"2026-04-09T08:16:22.000Z","published_at":"2012-08-10T13:04:11.000Z","restored_at":"2018-10-10T14:57:27.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eIn number theory, a prime number p is a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSophie Germain prime\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e if 2p + 1 is also prime. For example, 23 is a Sophie Germain prime because it is a prime and 2 × 23 + 1 = 47, and 47 is also a prime number. These numbers are named after French mathematician Marie-Sophie Germain.\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\u003eSee\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Sophie_Germain_prime\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSophie Germain prime\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e article on Wikipedia.\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\u003eIn this Problem , the input is a number and you must return true or false if this number is a Sophie Germain prime.\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\"}]}"},{"id":42454,"title":"Divisible by n, prime divisors (including powers)","description":"For this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\r\n\r\n  n = 1:10;\r\n  n_p = [2 3 4 5 7 8 9];\r\n\r\nSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e.","description_html":"\u003cp\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1:10;\r\nn_p = [2 3 4 5 7 8 9];\r\n\u003c/pre\u003e\u003cp\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_p] = prime_divisors_incl_powers(n)\r\n\r\nn_p = 1;\r\n\r\nend","test_suite":"%%\r\nn = 1:10;\r\nn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = [2:7 12:17 10 42:55 11 19:29];\r\nn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1:100;\r\nn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 41:59;\r\nn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 100:200;\r\nn_p = [101 103 107 109 113 121 125 127 128 131 137 139 149 151 157 163 167 169 173 179 181 191 193 197 199]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1000:1111;\r\nn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:10;\r\n\t\tn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 3\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\n\tcase 3\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = 1000:1111;\r\n\t\tn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":95,"test_suite_updated_at":"2017-03-20T19:03:08.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:55:28.000Z","updated_at":"2026-01-11T12:28:45.000Z","published_at":"2015-07-09T01:55:28.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\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\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[n = 1:10;\\nn_p = [2 3 4 5 7 8 9];]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":3001,"title":"Sphenic number sequence","description":"Sphenic numbers are positive integers that are products of three distinct prime numbers: 30, 42, 66, 70, 78, 102, 105, 110, 114, 130, ... For example, 30 = 2*3*5, 42 = 2*3*7, etc.\r\nReturn the numbers from the sphenic sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [66, 70, 78, 102, 105].\r\nThis problem is related to Problem 3002 and Problem 3003.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 123px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.5px; transform-origin: 407px 61.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eSphenic numbers\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 317.5px 8px; transform-origin: 317.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e are positive integers that are products of three distinct prime numbers: 30, 42, 66, 70, 78, 102, 105, 110, 114, 130, ... For example, 30 = 2*3*5, 42 = 2*3*7, etc.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 365px 8px; transform-origin: 365px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn the numbers from the sphenic sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [66, 70, 78, 102, 105].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 80px 8px; transform-origin: 80px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem is related to\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3002-not-square-free-number-sequence\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3002\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14px 8px; transform-origin: 14px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3003-mobius-function\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3003\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [arr] = sphenic_seq(n)\r\n\r\narr = n;\r\n\r\nend","test_suite":"%%\r\nn = 1:5;\r\narr_corr = [30, 42, 66, 70, 78];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 1:10;\r\narr_corr = [30, 42, 66, 70, 78, 102, 105, 110, 114, 130];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 3:7;\r\narr_corr = [66, 70, 78, 102, 105];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 20:30;\r\narr_corr = [222   230   231   238   246   255   258   266   273   282   285];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 69;\r\narr_corr = 582;\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 1:53;\r\narr_corr = [30, 42, 66, 70, 78, 102, 105, 110, 114, 130, 138, 154, 165, 170, 174, 182, 186, 190, 195, 222, 230, 231, 238, 246, 255, 258, 266, 273, 282, 285, 286, 290, 310, 318, 322, 345, 354, 357, 366, 370, 374, 385, 399, 402, 406, 410, 418, 426, 429, 430, 434, 435, 438];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%% prevents cheating\r\ni1 = randi(20,1);\r\nn = i1:(i1+randi(25,1));\r\narr_tot = [30, 42, 66, 70, 78, 102, 105, 110, 114, 130, 138, 154, 165, 170, 174, 182, 186, 190, 195, 222, 230, 231, 238, 246, 255, 258, 266, 273, 282, 285, 286, 290, 310, 318, 322, 345, 354, 357, 366, 370, 374, 385, 399, 402, 406, 410, 418, 426, 429, 430, 434, 435, 438];\r\narr_corr = arr_tot(n);\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":223089,"edited_at":"2022-10-09T05:23:45.000Z","deleted_by":null,"deleted_at":null,"solvers_count":87,"test_suite_updated_at":"2022-10-09T05:23:45.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-02-11T02:19:47.000Z","updated_at":"2026-03-16T14:15:22.000Z","published_at":"2015-02-11T02:19:47.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:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSphenic numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e are positive integers that are products of three distinct prime numbers: 30, 42, 66, 70, 78, 102, 105, 110, 114, 130, ... For example, 30 = 2*3*5, 42 = 2*3*7, etc.\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\u003eReturn the numbers from the sphenic sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [66, 70, 78, 102, 105].\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 problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3002-not-square-free-number-sequence\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3002\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3003-mobius-function\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3003\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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":60944,"title":"Ulam primes first formula","description":"Historical context\r\n\r\n\r\nThe polish-american mathematician Stanislaw Ulam found the formula  to give the first 760 prime numbers not given by Euler's formula. \r\n\r\n\r\nProblem statement\r\n\r\nFor a given integer m, m \u003e= 1847, list the Ulam prime numbers less or equal to m in a vector up. Also compute their frequency / ratio f compare to all the primes in the same range. If m is not a positive integer greater or equal to 1847, your function should return up = [] and f = 0.\r\n\r\nExamples\r\n\r\nIf m = 1847 then up = 1847 and f = 1 since 1847 = P(0) and it is the only prime number m greater or equal and less or equal to 1847;\r\nIf m = 3000 then up = [1847, 2203, 2393, 2591, 2797] and f = 5/148 since 1847 = P(0), 2203 = P(2), 2393 = P(3), 2591 = P(4), 2797 = P(5), and there are in total 30 prime numbers in the range [1847; 3000] ; \r\nIf m = 1823 then up = [] and f = 0;\r\n\r\n\r\nTip \r\n\r\nn is less or equal to 2000 here.\r\n\r\n\r\nFobidden functions\r\n\r\nregexp\r\nassignin\r\nstr2num\r\n\r\n\r\nSee also\r\nUlam primes second formula\r\nEuler primes\r\nPrime numbers properties II","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 1069.47px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 534.733px; transform-origin: 408px 534.733px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 58.725px 8px; transform-origin: 58.725px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eHistorical context\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 21px; text-align: left; transform-origin: 385px 21px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 219.4px 8px; transform-origin: 219.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe polish-american mathematician Stanislaw Ulam found the formula \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVQAAAAnCAYAAABQU7BuAAALq0lEQVR4Xu1dWehuUxR3I8qQ6cGQKDyYMs9ThlCG5MHwIN2QKUMeCA+6SWR6MGTKwyUZQ8qcKJIxIeIBRRlSpgwRYv04S+uuu/bZe5+99/ed8/+vU6v/vd+3zx5+e+3fXmvt4Vuyij+OgCPgCDgCVRBYUiUXz8QRcAQcAUdgFSdUVwJHwBFwBCoh4IRaCUjPxhFwBBwBJ1TXAUfAEXAEKiHghFoJyAWczVbUtqtITuja+BX9vZDkwQXcZm+aIzAIgXkS6hVU4+1IriF5c1Dt7ZcOp49PJnnSB30xqhtQDp+RrG3kdDZ9dntxCZ6BI7CAEJgXoT5GGO5P8g7JYZXxBAm8SLJF9/e4yvkvpuxghe5IciPJliQgUSZXWKqbLiYwvK2OQAwBTahn0QuXk2wSe5G+/5nkA5J3SR4heS7hHSQBmR7avbtP4ju5yUCqqNt6JM+QLGRS/ZDatw3J6yR75wLVkx6u/hMkR5N80qWDftwm3tmQ/v1dxTJbZ4U2nUmCiWGdQGHwcJ7NrMjWAiN+FWVdTHIgyY8km5O8THKZkTazuMknP5FagLDRSx1GfQ1iHHfqEq3b/f2c/oJLhnhJfWPmNcpzrwyEH6K0aM+/T8hCvZS+Q9xMP3vSB3DP0chbSaB8/GBAn9d9H6rPtfTFuSSrkWxM0nIwglQB+p8kl5AMAT4D17kkvYNKPaMruQWhAkMdjvm7Kw8W6g6N+7AWqNDT00g4Dox8c3U/VJeP6Itt1ZcoD0YGrPkjSGBs8JiCIXI6yWKLQUOXMJmBI9hgu47+jUkn9Ej9liEmObED//0y9DA2Zn7q+i1V906SfRlSKjT+W5WjNWA1m0NZ4GpbRMkzPwbkOSSzIDjEaWER/EGCwc+WVipYY06nLanahGq1XeoFSAJkMeYHA+8CEljw+gnpPohOEm+sfdCvq0UiGBsIZYFMdVjkS/oMZIJxsvMC08cQTryoeWSHiUzXR6gwvi7qElu6JrknVfdjYwZ1/TjW4eJ79OMKnk5fDJUtEX7fqrRlya5gAovCYensSoIZAK74rJ4fuka/TX/3mFWhjcuxFotSlaqkanBtHugI4RD6W3MxsaRe1rtw6+BSvkBylzGYQ7rP7mBqfbS7Lwe6JoIhJJBajzGmAz8cRALX/GASPVGFCFUbdFY6zT3sPYdwSBkzrN+pWK7EdaWEasWbrMWKeVinDMpN9A+4GXhioKcCOe90GJiIJUnLaxaEyoSgrbISPKQlwu5xSX7Wu7IM/j6k+zAkQIQ39FQCi3TAXrv7mLDfEO9pItD1GJM+sgHVUo+0kRYiVM0robCKjHXHdCdlzKB/EFqAZfxpoP93o885HLqCu4/0LQjVyhcNx2o+ypv1Qgab8ejMh0n+DyDXHrUzyo9nfSwGskuEolsOBOTPFkFNMkW+YyJUDOTlJH27F6T1pLGQ8Tm0LUaod1IaxBXH8IyZUIGP3qanLdQ+XkkdMyBd9H9fOJL7eCV3vxWh6oKkAn5BhW42B+2B2w+L7leSteZQfq0iYQE9ToJ4MBbaZkWoKBeuM2ZmGS/E56Vu/5gIlSfbvgUjuSCi3X0dLogRqmV51dKV3HzGRKja0ue2SFKV4ZO+WGzOmEG/xwwujoOboc0WFqqOG8m4xN1U4aWBnuaG6y1bbMpj4B1DAlcLpP1UN2ul7BR4ldLylqIxuVk5So+J6RUSLLIAY+0+agtVW0soi9MA6ytJ9iXB4gkG9jISi0hQ7vskNysyRb+eSlK6MDUmQk3pDyZNiwxjLm0o9NBS91PahDRjIlTUJ7R9CUT2KAnH8vUkL9ubO2ZiWEkuW8ndx8ulhGqtiOpYhlSi2DYJK3CMimOwWyu1qTO8rMNUT/iAIPGwixgjVKS10iynz+VeUqlEWklYIeFVYF+vfLBXL9afMQXVdYzFwVLys9LkxFD7ypCrwNrdt6yqmIWKsniCb6X7qZiNjVDZK7JO6aFNIFaM5T6DasiY6cOL+c509/FiCaHqTd7IzyIrxE95v2rKgNEzE6wqkAAAXJ8Em6OlFZtCkDmknjogUxVVpxtyOg0z4zISud8uhVB1cB8LhsDvehK46joPvaAo+85qrzlLZwIzJQtVxu20u28t0KYQqhwTLXQ/tTvGRqiod4xU+yb0oWOmDy/eoxrayZRFqBhs95Jgn+kBitRgKbIrqisklWQIoWrQtCubsh9SKnsQjB4kLQsnVVFLCZUtF71NaQihoi6S0K39xmwxWSED3ZYaC4xTIlSOn6WsOgOrUkKtofupejpGQkXdoaP3k8hDRLJN1nguGTMhvKQBGTQkcixUJlRZ4Pf0n+c7aydUkdqEmkIkui6SUIeshgPMpamaGUmXezwU+FlH9FJwsKwm3ec67pcy6VWC4t9spkKo0qW3djq0sFBjhDxEl0N9N0ZC5Vg/sIXhxDF/3Qa9W6JkzITwYW8t6O5ra0VnlLKxP2VgLQRCTWlnizRwMU8h0UcbNRHh/9bgGgOh1rTuh5J9jRiqtNits/tjJ1Q9nofqawmJxxbtZJ2kRcihKBDsPSTWegr3SemYsXCRnlyvh5tjoQ4FcgyEKlfnxrT3L6bUUEAoE+4k0A8u25CxZHlZDS9cOaH+h1oNQuX4Wd9CaIwwYvXQMdSaFuqUCFUe30X/yXUSXijVpMpYlY4Za0zK2HnvusEsCFXuBEixMFooVemiVIz4Wn0/ZBDIiW8MhBoLl8iJAWSFm5lCT+zyndB7MSKL9Z+ckPsONpTuQ22h+9w25N338A1LPDGH0uJAydDDCLEJh8vUm/a1R2DtiGDLsXTMWO3mfu119/HiLAg1l8xaKJWsw5CV6Zpua84qf6lyjIFQY2Q1hRiqNAosd5/bWHpSqoXux/Dn78cUQ9XbMa0xo9Ow51k6ZjRecqtcdEF7FoQqBzVu0cf9mn1PC6WSlkPfgMixcFIVVafLIdQ+q2IqLn8Mp7ETqrSGYvueS8/yt9D9GP5jJFQ9MVljRhs57DmUjhmNV5YxNgtCRQV/IVmTJOXoaQul+p3KXp3kG5KNUjVMpIu5rTlZ5q7yp5L8WBelYtiMnVDl4kjKPQZy767e0ie/s/qrhe7H8B8joeo97pYRpEk3xVBK2Rmj8ZJXLoYuJf//nRChWvcCRuMHPT0H8/x4EpQXa3htpZIWco2TPakK2jpdinK4y/9fL1ghm9Q9tJIEU97puw9VxuKs+1Br636ODs7D5Q8tEPNxZ150tcYtEx3amLrQnDJmJGbS40gqI0SooU3dQ8/By4GNM+HnB3raCjbrhujYScwNw894HNWVFyPzHAWcd9oU5YgRiTVxDokxl2DR2kLVg5PrmmJtDr1QW57wYTx5DMAwse6SbaH7Of3SmlD1QhPq1verD/J+A/krB8AJR6f5btUkouuASBkzEjPJg0ncN+Q3pQACbsLPvXE/dsF06IIIOQNZdwfge5Aq9mvqm48A/tckUJblJENXJ3MUc1ZpY8oRmhTRf8d2lcQNUvqsNJT3vhli1YpQOZbW9/tAvKsgtHtAkkDKEWfZ99A93AiGC32wcwG3neGABvLU589b6H6uHrYgVA6V6Xi/rJu13Y+/B4YgzqUk2wtdRb+9R8JHqFPbGhszOh/eKmfd8WyWmbNAklrpUDpYQ7i1aA2SW0hCVmppOfJ9HFnDlpffSHDBR8rNVDXL97ziCLQi1HjJnkIi0IJQFx3CsyRUgIsZC7PKqiT4NcjSuzT7Ogwu1tMkf5FgZwEWCPwZHwJywW/oPtPxtWp6NWKLvmSf6fRaXbnGsyZUVB8WCVxvXPYMM76F1QhXYaH/4mllVfDsHAFHoBSBeRAqW6rLOlLdvTKpgkzfIsE2LZSRG+stxdTfdwQcgUWKwLwIFXDDJd+FBAsjNV3/VvkuUhXxZjsCjkAqAvMk1NQ6ejpHwBFwBCaBgBPqJLrJK+kIOAJTQMAJdQq95HV0BByBSSDghDqJbvJKOgKOwBQQcEKdQi95HR0BR2ASCPwDPACqVQlvtokAAAAASUVORK5CYII=\" width=\"170\" height=\"19.5\" style=\"width: 170px; height: 19.5px;\"\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63px 8px; transform-origin: 63px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e to give the first 760 prime numbers not given by Euler's formula. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63.0083px 8px; transform-origin: 63.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eProblem statement\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 31.5px; text-align: left; transform-origin: 385px 31.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 60.2917px 8px; transform-origin: 60.2917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor a given integer \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 6.225px 8px; transform-origin: 6.225px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 33.8583px 8px; transform-origin: 33.8583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em \u0026gt;= 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 138.475px 8px; transform-origin: 138.475px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003elist the Ulam prime numbers less or equal to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 5.83333px 8px; transform-origin: 5.83333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003em\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40.0583px 8px; transform-origin: 40.0583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e in a vector u\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ep\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63.7833px 8px; transform-origin: 63.7833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Also compute their frequency / ratio \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ef \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 286.658px 8px; transform-origin: 286.658px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ecompare to all the primes in the same range. If m is not a positive integer greater or equal to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5667px 8px; transform-origin: 15.5667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eyour function should return\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.075px 8px; transform-origin: 25.075px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e up = [] \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 11.675px 8px; transform-origin: 11.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 18.0833px 8px; transform-origin: 18.0833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e f = 0.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 32.675px 8px; transform-origin: 32.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExamples\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 102.167px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 51.0833px; transform-origin: 392px 51.0833px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 5.825px 8px; transform-origin: 5.825px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 29.7667px 8px; transform-origin: 29.7667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em = 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethen\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 6.21667px 8px; transform-origin: 6.21667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e u\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 27.8167px 8px; transform-origin: 27.8167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ep = 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.675px 8px; transform-origin: 11.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 16.1417px 8px; transform-origin: 16.1417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ef = 1 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 33.85px 8px; transform-origin: 33.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.2px 8px; transform-origin: 21.2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e = P(0)\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 99.575px 8px; transform-origin: 99.575px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and it is the only prime number \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 5.83333px 8px; transform-origin: 5.83333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003em\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 81.3px 8px; transform-origin: 81.3px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e greater or equal and less or equal to 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2.33333px 8px; transform-origin: 2.33333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 5.825px 8px; transform-origin: 5.825px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 29.7667px 8px; transform-origin: 29.7667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em = 3000\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethen\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 6.21667px 8px; transform-origin: 6.21667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e u\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 110.283px 8px; transform-origin: 110.283px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ep = [1847, 2203, 2393, 2591, 2797]\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.675px 8px; transform-origin: 11.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 29.7583px 8px; transform-origin: 29.7583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ef = 5/148 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 18.2833px 8px; transform-origin: 18.2833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 121.95px 8px; transform-origin: 121.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e1847 = P(0), 2203 = P(2), 2393 = P(3), 2591 = P(4), 2797 = P(5), \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 73.9083px 8px; transform-origin: 73.9083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand there are in total 30\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 85.5833px 8px; transform-origin: 85.5833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eprime numbers in the range\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 46.6667px 8px; transform-origin: 46.6667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e [1847; 3000] ; \u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 31.7083px 8px; transform-origin: 31.7083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em = 1823 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 19.45px 8px; transform-origin: 19.45px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethen u\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 16.9167px 8px; transform-origin: 16.9167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ep = []\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 14.2px 8px; transform-origin: 14.2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ef = 0\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 10.3667px 8px; transform-origin: 10.3667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eTip\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 91.8px 8px; transform-origin: 91.8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is less or equal to 2000 here.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 64.9167px 8px; transform-origin: 64.9167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eFobidden functions\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 30.65px; transform-origin: 392px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.4px 8px; transform-origin: 21.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eregexp\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.6833px 8px; transform-origin: 25.6833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eassignin\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.2833px 8px; transform-origin: 25.2833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003estr2num\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.3917px 8px; transform-origin: 28.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eSee also\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/groups/95630/problems/60943-ulam-primes-second-formula/\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eUlam primes second formula\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/problems/60942-euler-primes\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eEuler primes\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/groups/95759\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ePrime numbers properties II\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [up,f] = ulam_primes1(m)\r\n  up = m;\r\n  f = 1;\r\nend","test_suite":"%%\r\nm = 1847;\r\nup_correct = 1847;\r\nf_correct = 1;\r\n[up,f] = ulam_primes1(m);\r\nassert(isequal([up,f],[up_correct,f_correct]));\r\n\r\n%%\r\nm = 3000;\r\nup_correct = [1847, 2203, 2393, 2591, 2797];\r\nf_correct = 5/148;\r\n[up,f] = ulam_primes1(m);\r\nassert(isequal([up,f],[up_correct,f_correct]));\r\n\r\n%%\r\nm = 1823;\r\nup_correct = [];\r\nf_correct = 0;\r\n[up,f] = ulam_primes1(m);\r\nassert(isequal([up,f],[up_correct,f_correct]));\r\n\r\n%% Forbidden functions\r\nfiletext = fileread('ulam_primes1.m');\r\nillegal = contains(filetext, 'regexp') || contains(filetext, 'str2num') || contains(filetext, 'assignin') || contains(filetext, 'echo')\r\nassert(~illegal);","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":149128,"edited_by":149128,"edited_at":"2025-07-26T07:08:08.000Z","deleted_by":null,"deleted_at":null,"solvers_count":20,"test_suite_updated_at":"2025-07-09T05:56:57.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2025-06-26T19:59:43.000Z","updated_at":"2026-03-17T10:54:41.000Z","published_at":"2025-06-26T20:23:34.000Z","restored_at":null,"restored_by":null,"spam":null,"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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHistorical context\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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\u003eThe polish-american mathematician Stanislaw Ulam found the formula \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\mathbf{P(n) = 4n^2 + 170n + 1847}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e to give the first 760 prime numbers not given by Euler's formula. \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\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eProblem statement\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\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\u003eFor a given integer \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em \u0026gt;= 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003elist the Ulam prime numbers less or equal to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in a vector u\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Also compute their frequency / ratio \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ecompare to all the primes in the same range. If m is not a positive integer greater or equal to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eyour function should return\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e up = [] \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = 0.\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em = 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e u\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep = 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef = 1 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003esince 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e = P(0)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and it is the only prime number \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e greater or equal and less or equal to 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em = 3000\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e u\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep = [1847, 2203, 2393, 2591, 2797]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef = 5/148 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003esince \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1847 = P(0), 2203 = P(2), 2393 = P(3), 2591 = P(4), 2797 = P(5), \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand there are in total 30\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eprime numbers in the range\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e [1847; 3000] ; \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em = 1823 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ethen u\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep = []\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef = 0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTip\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is less or equal to 2000 here.\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\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFobidden functions\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexp\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassignin\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estr2num\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\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSee also\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/groups/95630/problems/60943-ulam-primes-second-formula/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUlam primes second formula\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/problems/60942-euler-primes\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eEuler primes\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/groups/95759\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePrime numbers properties II\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":42510,"title":"Divisible by n, Composite Divisors","description":"Pursuant to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\r\n\r\nAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\r\n\r\nThe only restriction that remains is Java.\r\n\r\n* Divisible by 2: if the last digit is divisible by 2.\r\n* Divisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\r\n* Divisible by 4: if the last two digits are divisible by 4.\r\n* Divisible by 5: if the last digit is a 0 or 5.\r\n* Divisible by 8: if the last three digits are divisible by 8.\r\n* Divisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\r\n* Divisible by 10: if the last digit is zero.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors Divisible by n, Truncated-number Divisors\u003e.","description_html":"\u003cp\u003ePursuant to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\u003c/p\u003e\u003cp\u003eAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\u003c/p\u003e\u003cp\u003eThe only restriction that remains is Java.\u003c/p\u003e\u003cul\u003e\u003cli\u003eDivisible by 2: if the last digit is divisible by 2.\u003c/li\u003e\u003cli\u003eDivisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/li\u003e\u003cli\u003eDivisible by 4: if the last two digits are divisible by 4.\u003c/li\u003e\u003cli\u003eDivisible by 5: if the last digit is a 0 or 5.\u003c/li\u003e\u003cli\u003eDivisible by 8: if the last three digits are divisible by 8.\u003c/li\u003e\u003cli\u003eDivisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/li\u003e\u003cli\u003eDivisible by 10: if the last digit is zero.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\"\u003eDivisible by n, Truncated-number Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = composite_divisors(n,n_str)\r\n\r\ntf = 1;\r\n\r\nend\r\n","test_suite":"%%\r\nfiletext = fileread('composite_divisors.m');\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 18;\r\nn_str = '612220032';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '612220031';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '64268410079232';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '64268410079230';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 30;\r\nn_str = '64268410079230';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 30;\r\nn_str = '64268410079220';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 90;\r\nn_str = '47829690000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 90;\r\nn_str = '47829690000001';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '101559956668416';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '101559956668417';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '3046798700052480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '3046798700052480000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '262144000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '262144000000008';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '52428800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '52428800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '4586471424';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '45864714247';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '26418075402240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '26418075402240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":76,"test_suite_updated_at":"2015-08-18T17:06:20.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-18T01:06:51.000Z","updated_at":"2026-01-11T11:13:47.000Z","published_at":"2015-08-18T01:06:51.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\u003ePursuant to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\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\u003eAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\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 only restriction that remains is Java.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 2: if the last digit is divisible by 2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 4: if the last two digits are divisible by 4.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 5: if the last digit is a 0 or 5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 8: if the last three digits are divisible by 8.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 10: if the last digit is zero.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Truncated-number Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"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":42914,"title":"Counting the Grand Primes","description":"A grand prime pair is a pair of primes, p1 and p2=p1+1000, such that both numbers are prime. Like a twin prime pair, where the difference is 2, the members of a grand prime pair always have a difference of 1000. Some facts about grand prime pairs, so that you can test your code:\r\n\r\n1. The smallest grand prime pair is [13,1013], the 100th such pair is [3229,4229].\r\n\r\n2. There are 37 grand prime pairs such that the larger element of the pair is no larger than 2000.\r\n\r\n3. There should be infinitely many grand prime pairs.\r\n\r\n4. All such grand prime pairs must have the property that the smaller element of the pair is of the form 6*k+1, for some integer k.\r\n\r\nWrite a function that counts the number of grand prime pairs that exist, such that the larger element of the pair is no larger than N. I'll be nice and not ask you to compute that result for N too large, 1e8 seems a reasonable upper limit.","description_html":"\u003cp\u003eA grand prime pair is a pair of primes, p1 and p2=p1+1000, such that both numbers are prime. Like a twin prime pair, where the difference is 2, the members of a grand prime pair always have a difference of 1000. Some facts about grand prime pairs, so that you can test your code:\u003c/p\u003e\u003cp\u003e1. The smallest grand prime pair is [13,1013], the 100th such pair is [3229,4229].\u003c/p\u003e\u003cp\u003e2. There are 37 grand prime pairs such that the larger element of the pair is no larger than 2000.\u003c/p\u003e\u003cp\u003e3. There should be infinitely many grand prime pairs.\u003c/p\u003e\u003cp\u003e4. All such grand prime pairs must have the property that the smaller element of the pair is of the form 6*k+1, for some integer k.\u003c/p\u003e\u003cp\u003eWrite a function that counts the number of grand prime pairs that exist, such that the larger element of the pair is no larger than N. I'll be nice and not ask you to compute that result for N too large, 1e8 seems a reasonable upper limit.\u003c/p\u003e","function_template":"function y = grandPrimeCounter(N)\r\n  y = N;\r\nend","test_suite":"%%\r\nN = 1000;\r\ny_correct = 0;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 1234;\r\ny_correct = 13;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 12345;\r\ny_correct = 280;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 123456;\r\ny_correct = 1925;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 1234567;\r\ny_correct = 13142;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 99999900;\r\ny_correct = 586509;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":544,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-07-22T17:41:15.000Z","updated_at":"2026-03-16T15:24:57.000Z","published_at":"2016-07-22T18:20:37.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eA grand prime pair is a pair of primes, p1 and p2=p1+1000, such that both numbers are prime. Like a twin prime pair, where the difference is 2, the members of a grand prime pair always have a difference of 1000. Some facts about grand prime pairs, so that you can test your code:\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\u003e1. The smallest grand prime pair is [13,1013], the 100th such pair is [3229,4229].\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\u003e2. There are 37 grand prime pairs such that the larger element of the pair is no larger than 2000.\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\u003e3. There should be infinitely many grand prime pairs.\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\u003e4. All such grand prime pairs must have the property that the smaller element of the pair is of the form 6*k+1, for some integer k.\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\u003eWrite a function that counts the number of grand prime pairs that exist, such that the larger element of the pair is no larger than N. I'll be nice and not ask you to compute that result for N too large, 1e8 seems a reasonable upper limit.\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\"}]}"},{"id":3003,"title":"Mobius function","description":"From wikipedia:\r\nFor any positive integer n, define μ(n) as the sum of the primitive n-th roots of unity. It has values in {−1, 0, 1} depending on the factorization of n into prime factors:\r\nμ(n) = 1 if n is a square-free positive integer with an even number of prime factors.\r\nμ(n) = −1 if n is a square-free positive integer with an odd number of prime factors.\r\nμ(n) = 0 if n has a squared prime factor.\r\nReturn numbers from the Mobius function sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [-1, 0, -1, 1, -1].\r\nHint: solving Problem 3001 and Problem 3002 will provide much of the code needed for this problem. You'll need to add prime numbers to the sphenic number set (resulting from Problem 3001).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 256.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 128.15px; transform-origin: 407px 128.15px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 16.5px 8px; transform-origin: 16.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFrom\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ewikipedia\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 380px 8px; transform-origin: 380px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor any positive integer n, define μ(n) as the sum of the primitive n-th roots of unity. It has values in {−1, 0, 1} depending on the factorization of n into prime factors:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 30.65px; transform-origin: 391px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 259px 8px; transform-origin: 259px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eμ(n) = 1 if n is a square-free positive integer with an even number of prime factors.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 259.5px 8px; transform-origin: 259.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eμ(n) = −1 if n is a square-free positive integer with an odd number of prime factors.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 125px 8px; transform-origin: 125px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eμ(n) = 0 if n has a squared prime factor.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 79px 8px; transform-origin: 79px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn numbers from the\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eMobius function sequence\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 214.5px 8px; transform-origin: 214.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e corresponding to the supplied indices. For example, if n = 3:7, your function should return [-1, 0, -1, 1, -1].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 38px 8px; transform-origin: 38px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHint: solving\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3001-sphenic-number-sequence\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3001\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14px 8px; transform-origin: 14px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3002-not-square-free-number-sequence\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3002\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 232.5px 8px; transform-origin: 232.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e will provide much of the code needed for this problem. You'll need to add prime numbers to the sphenic number set (resulting from Problem 3001).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [arr] = mobius_func_seq(n)\r\n\r\narr =n;\r\n\r\nend\r\n","test_suite":"%%\r\nn = 1:5;\r\narr_corr = [1, -1, -1, 0, -1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 1:10;\r\narr_corr = [1, -1, -1, 0, -1, 1, -1, 0, 0, 1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 3:7;\r\narr_corr = [-1, 0, -1, 1, -1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 20:30;\r\narr_corr = [0     1     1    -1     0     0     1     0     0    -1    -1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 99;\r\narr_corr = 0;\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 1:77;\r\narr_corr = [1, -1, -1, 0, -1, 1, -1, 0, 0, 1, -1, 0, -1, 1, 1, 0, -1, 0, -1, 0, 1, 1, -1, 0, 0, 1, 0, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, 1, 1, 0, -1, -1, -1, 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 1, 0, 1, 1, -1, 0, -1, 1, 0, 0, 1, -1, -1, 0, 1, -1, -1, 0, -1, 1, 0, 0, 1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%% prevents cheating\r\ni1 = randi(20,1);\r\nn = i1:(i1+randi(25,1));\r\narr_tot = [1, -1, -1, 0, -1, 1, -1, 0, 0, 1, -1, 0, -1, 1, 1, 0, -1, 0, -1, 0, 1, 1, -1, 0, 0, 1, 0, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, 1, 1, 0, -1, -1, -1, 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 1, 0, 1, 1, -1, 0, -1, 1, 0, 0, 1, -1, -1, 0, 1, -1, -1, 0, -1, 1, 0, 0, 1];\r\narr_corr = arr_tot(n);\r\nassert(isequal(mobius_func_seq(n),arr_corr))","published":true,"deleted":false,"likes_count":5,"comments_count":3,"created_by":26769,"edited_by":223089,"edited_at":"2022-10-09T11:44:37.000Z","deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":"2022-10-09T11:44:37.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-02-11T03:05:35.000Z","updated_at":"2026-03-16T14:39:18.000Z","published_at":"2015-02-11T03:05:35.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\u003eFrom\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ewikipedia\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\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\u003eFor any positive integer n, define μ(n) as the sum of the primitive n-th roots of unity. It has values in {−1, 0, 1} depending on the factorization of n into prime factors:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eμ(n) = 1 if n is a square-free positive integer with an even number of prime factors.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eμ(n) = −1 if n is a square-free positive integer with an odd number of prime factors.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eμ(n) = 0 if n has a squared prime factor.\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\u003eReturn numbers from the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMobius function sequence\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e corresponding to the supplied indices. For example, if n = 3:7, your function should return [-1, 0, -1, 1, -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\u003eHint: solving\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3001-sphenic-number-sequence\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3001\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3002-not-square-free-number-sequence\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3002\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e will provide much of the code needed for this problem. You'll need to add prime numbers to the sphenic number set (resulting from Problem 3001).\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":42453,"title":"Divisible by n, prime vs. composite divisors","description":"In general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\r\n\r\n  n = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\n  n = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\n  n = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\n  n = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\n  n = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\n  n = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\n  n = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\n  n = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\n  n = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\n  n = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16 divisible by 16\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e.","description_html":"\u003cp\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\u003c/pre\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\"\u003edivisible by 16\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_type,hpf] = composite_vs_prime_divisor(n)\r\n\r\nn_type = 1;\r\nhpf = [1];\r\n\r\nend\r\n","test_suite":"%%\r\nn = 5;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 5;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 7;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 7;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 15;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,5];\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 25;\r\ntf_corr = 2; %composite factor, prime power (5^2)\r\nhpf_corr = 25;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 125;\r\ntf_corr = 2; %composite factor, prime power (5^3)\r\nhpf_corr = 125;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 20;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [4,5];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 42;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,3,7];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 18;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,9];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 29;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 29;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 39;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,13];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 64;\r\ntf_corr = 2; %composite factor, prime power (2^6)\r\nhpf_corr = 64;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 27;\r\ntf_corr = 2; %composite factor, prime power (3^3)\r\nhpf_corr = 27;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 29;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 29;\r\n\tcase 2\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 64;\r\n\t\ttf_corr = 2; %composite factor, prime power (2^6)\r\n\t\thpf_corr = 64;\r\n\tcase 2\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\n\tcase 3\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 4\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 39;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [3,13];\r\n\tcase 2\r\n\t\tn = 5;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 5;\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":113,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:29:13.000Z","updated_at":"2026-01-11T11:07:59.000Z","published_at":"2015-07-09T01:29:13.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\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\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[n = 11  |  n_type = 1 (prime)        |  hpf = [11]\\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\\\"\u003e\u003cw:r\u003e\u003cw:t\u003edivisible by 16\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":525,"title":"Mersenne Primes","description":"A Mersenne prime is a prime number of the form M = 2^p - 1, where p is another prime number.  For example, 31 is a Mersenne prime because 31 = 2^5 - 1 and both 31 and 5 are prime numbers.\r\n\r\nImplement the function isMersenne(x) so that it returns true if x is a Mersenne prime and false otherwise.  Your solution should work for all positive integer values of x less than 1,000,000,000 (one billion).","description_html":"\u003cp\u003eA Mersenne prime is a prime number of the form M = 2^p - 1, where p is another prime number.  For example, 31 is a Mersenne prime because 31 = 2^5 - 1 and both 31 and 5 are prime numbers.\u003c/p\u003e\u003cp\u003eImplement the function isMersenne(x) so that it returns true if x is a Mersenne prime and false otherwise.  Your solution should work for all positive integer values of x less than 1,000,000,000 (one billion).\u003c/p\u003e","function_template":"function y = isMersenne(x)\r\n  y = false;\r\nend","test_suite":"%%\r\nx = 3;\r\ny_correct = true;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 127;\r\ny_correct = true;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 157;\r\ny_correct = false;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 2047;\r\ny_correct = false;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 8191;\r\ny_correct = true;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 524287;\r\ny_correct = true;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 536870911;\r\ny_correct = false;\r\nassert(isequal(isMersenne(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":4,"created_by":1537,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":968,"test_suite_updated_at":"2012-03-24T15:03:26.000Z","rescore_all_solutions":false,"group_id":44,"created_at":"2012-03-24T14:32:54.000Z","updated_at":"2026-04-09T08:32:03.000Z","published_at":"2012-03-24T14:36:27.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eA Mersenne prime is a prime number of the form M = 2^p - 1, where p is another prime number. For example, 31 is a Mersenne prime because 31 = 2^5 - 1 and both 31 and 5 are prime numbers.\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\u003eImplement the function isMersenne(x) so that it returns true if x is a Mersenne prime and false otherwise. Your solution should work for all positive integer values of x less than 1,000,000,000 (one billion).\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\"}]}"},{"id":1722,"title":"Find the next prime number","description":"Find the next prime number or numbers for given n. For example:\r\n\r\n  n = 1;\r\n  out = 2;\r\n\r\nor\r\n\r\n  n = [5 7];\r\n  out = [7 11];\r\n\r\nGood luck!\r\n","description_html":"\u003cp\u003eFind the next prime number or numbers for given n. For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1;\r\nout = 2;\r\n\u003c/pre\u003e\u003cp\u003eor\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = [5 7];\r\nout = [7 11];\r\n\u003c/pre\u003e\u003cp\u003eGood luck!\u003c/p\u003e","function_template":"function y = nextprimenum(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nn = 1;\r\nout = 2;\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = 7;\r\nout = 11;\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = [1 2 3 4 5 6 7 8 9];\r\nout = [2 3 5 5 7 7 11 11 11];\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = [71 25 63 47 65 36 47 58 69];\r\nout = [73 29 67 53 67 37 53 59 71];\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = [171 255 636 487 675 369 477 538 969];\r\nout =  [173 257 641 491 677 373 479 541 971];\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = [172541 255564 632436 4564587 6778675 334469 475647 575638 96879];\r\nout =  [172553 255571 632447 4564589 6778691 334487 475649 575647 96893];\r\nassert(isequal(nextprimenum(n),out))","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":15013,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":837,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-17T21:54:33.000Z","updated_at":"2026-04-09T08:29:05.000Z","published_at":"2013-07-17T21:54:32.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\u003eFind the next prime number or numbers for given n. For example:\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[n = 1;\\nout = 2;]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eor\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[n = [5 7];\\nout = [7 11];]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood luck!\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\"}]}"},{"id":42508,"title":"Divisible by n, prime divisors from 20 to 200","description":"Pursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\r\n\r\n* 2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u003e 2048379 is not divisible by 127 since 54 is not divisible by 127.\r\n\r\n* 4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u003e 4853940 is divisible by 127.\r\n\r\nYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\r\n\r\nRestrictions on Java, mod, ceil, round, and floor are still in effect.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors Divisible by n, Truncated-number Divisors\u003e.","description_html":"\u003cp\u003ePursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\u003c/p\u003e\u003cul\u003e\u003cli\u003e2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u0026gt; 2048379 is not divisible by 127 since 54 is not divisible by 127.\u003c/li\u003e\u003c/ul\u003e\u003cul\u003e\u003cli\u003e4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u0026gt; 4853940 is divisible by 127.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\u003c/p\u003e\u003cp\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\"\u003eDivisible by n, Truncated-number Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = prime_divisors_20_to_200(n,n_str)\r\n\r\np_digits =      [23 29  31 37  41 43  47 53 59 61 67  71 73 79 83 89 97  101 103 107 109 113 127 131 137 139  149  151 157 163  167 173  179  181 191 193  197 199];\r\nlast_dig_mult = [7  3  -3 -11 -4  13 -14 16 6 -6 -20 -7 -51 8  25 9 -29 -10 -72 -32 -98 -79 -38 -13 -41 -125 -134 -15 -47 -114 -50 -121 -161 -18 -19 -135 -59 -179];\r\n\r\ntf = 1;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('prime_divisors_20_to_200.m');\r\nassert(isempty(strfind(filetext, 'rem')),'rem() forbidden')\r\nassert(isempty(strfind(filetext, 'mod')),'mod() forbidden')\r\nassert(isempty(strfind(filetext, 'round')),'round() forbidden')\r\nassert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden')\r\nassert(isempty(strfind(filetext, 'floor')),'floor() forbidden')\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 23;\r\nn_str = '943';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 23;\r\nn_str = '9430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 23;\r\nn_str = '9430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 29;\r\nn_str = '22649';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '992';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '9920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '9920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 37;\r\nn_str = '4107';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 41;\r\nn_str = '33292';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '85140';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '851400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '851400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 47;\r\nn_str = '232603';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 53;\r\nn_str = '148877';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 59;\r\nn_str = '12698688';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '61965813';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '619658130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '619658130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 67;\r\nn_str = '22319844';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 71;\r\nn_str = '25411681';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 73;\r\nn_str = '328500';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 73;\r\nn_str = '32850000000000000000000000000000000000000000000000000000000000001000000000000';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 79;\r\nn_str = '41977440';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 83;\r\nn_str = '342873';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 89;\r\nn_str = '8900000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 97;\r\nn_str = '88529281';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '104060401';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '1040604010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '1040604010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 103;\r\nn_str = '112550881';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 107;\r\nn_str = '515205';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 109;\r\nn_str = '141158161';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294000000000000000000000000113000000000000000000000000113000000000000000000000000113000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294000000000000000000000000113000000000000000000000000113000000000000000000000000113000000000000000000000112';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 127;\r\nn_str = '4853940';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 131;\r\nn_str = '294499921';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 137;\r\nn_str = '249421241';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '2685619';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '268561900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '268561900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000000000000000013';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 149;\r\nn_str = '512977200';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 151;\r\nn_str = '141160991';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 157;\r\nn_str = '607573201';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 163;\r\nn_str = '705911761';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 167;\r\nn_str = '777796321';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 173;\r\nn_str = '154963892093';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 179;\r\nn_str = '98682340334763';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 181;\r\nn_str = '35161828327081';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 191;\r\nn_str = '884089868985578';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 193;\r\nn_str = '1387488001';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 197;\r\nn_str = '27000544548887';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '328039798800';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000199000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000001991000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000199000000000000';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-17T19:05:44.000Z","updated_at":"2025-12-27T11:58:28.000Z","published_at":"2015-08-17T19:05:44.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\u003ePursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u0026gt; 2048379 is not divisible by 127 since 54 is not divisible by 127.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u0026gt; 4853940 is divisible by 127.\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\u003eYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\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\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Truncated-number Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":42455,"title":"Divisible by n, prime divisors - 11, 13, 17, \u0026 19","description":"Divisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\r\n\r\n* 2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u003e 2392 is divisible by 13.\r\n\r\nFor 17, subtract five times the last digit from the rest:\r\n\r\n* 3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u003e 3281 is divisible by 17.\r\n\r\nFor 19, add two times the last digit to the rest:\r\n\r\n* 16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u003e 16863 is not divisible by 19.\r\n\r\nAnd, for 11, subtract the last digit from the rest:\r\n\r\n* 269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u003e 269830 is divisible by 11.\r\n\r\nWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\r\n\r\nRestrictions on Java, mod, ceil, round, and floor are still in effect.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200 Divisible by n, prime divisors from 20 to 200\u003e.","description_html":"\u003cp\u003eDivisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u0026gt; 2392 is divisible by 13.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 17, subtract five times the last digit from the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u0026gt; 3281 is divisible by 17.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 19, add two times the last digit to the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u0026gt; 16863 is not divisible by 19.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eAnd, for 11, subtract the last digit from the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u0026gt; 269830 is divisible by 11.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\u003c/p\u003e\u003cp\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\"\u003eDivisible by n, prime divisors from 20 to 200\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = prime_divisors_11_to_20(n)\r\n\r\np_digits = [11 13 17 19];\r\ntf = zeros(1,4); %[11 13 17 19]\r\n\t\r\nend\r\n","test_suite":"%%\r\nfiletext = fileread('prime_divisors_11_to_20.m');\r\nassert(isempty(strfind(filetext, 'mod')),'mod() forbidden')\r\nassert(isempty(strfind(filetext, 'round')),'round() forbidden')\r\nassert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden')\r\nassert(isempty(strfind(filetext, 'floor')),'floor() forbidden')\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = '143';\r\ntf = [1 1 0 0]; %[11 13 17 19]\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '187';\r\ntf = [1 0 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '221';\r\ntf = [0 1 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '247';\r\ntf = [0 1 0 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '46189';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '2133423721';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '233296158667';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010101';\r\ntf = [0 0 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010103';\r\ntf = [0 1 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010107';\r\ntf = [0 0 0 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%\r\nn = '14300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = [1 1 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '14300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = [0 0 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '22100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = [0 1 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '221';\r\n\t\ttf = [0 1 1 0];\r\n\tcase 2\r\n\t\tn = '233296158667';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 3\r\n\t\tn = '46189';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 4\r\n\t\tn = '247';\r\n\t\ttf = [0 1 0 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '187';\r\n\t\ttf = [1 0 1 0];\r\n\tcase 2\r\n\t\tn = '143';\r\n\t\ttf = [1 1 0 0];\r\n\tcase 3\r\n\t\tn = '221';\r\n\t\ttf = [0 1 1 0];\r\n\tcase 4\r\n\t\tn = '233296158667';\r\n\t\ttf = [1 1 1 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '2133423721';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 2\r\n\t\tn = '46189';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 3\r\n\t\tn = '187';\r\n\t\ttf = [1 0 1 0];\r\n\tcase 4\r\n\t\tn = '247';\r\n\t\ttf = [0 1 0 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":73,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T04:18:06.000Z","updated_at":"2025-12-28T20:47:42.000Z","published_at":"2015-07-09T04:18:06.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\u003eDivisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u0026gt; 2392 is divisible by 13.\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\u003eFor 17, subtract five times the last digit from the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u0026gt; 3281 is divisible by 17.\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\u003eFor 19, add two times the last digit to the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u0026gt; 16863 is not divisible by 19.\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\u003eAnd, for 11, subtract the last digit from the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u0026gt; 269830 is divisible by 11.\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\u003eWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\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\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors from 20 to 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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":45201,"title":"Check if integer is a prime number","description":"Check if integer i is a prime number. Returns logical true '1' if it is.","description_html":"\u003cp\u003eCheck if integer i is a prime number. Returns logical true '1' if it is.\u003c/p\u003e","function_template":"function b = isPrime(i)\r\n  b = false;\r\nend","test_suite":"%%\r\nassert(isequal(isPrime(2),true))\r\n%%\r\nassert(isequal(isPrime(1),false))\r\n%%\r\nassert(isequal(isPrime(3),true))\r\n%%\r\nassert(isequal(isPrime(11),true))\r\n%%\r\nassert(isequal(isPrime(97),true))\r\n%%\r\nassert(isequal(isPrime(199),true))\r\n%%\r\nassert(isequal(isPrime(65),false))\r\n%%\r\nassert(isequal(isPrime(93),false))\r\n%%\r\nassert(isequal(isPrime(77),false))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":348097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":"2019-11-12T08:49:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-11-11T17:02:13.000Z","updated_at":"2026-02-19T14:28:53.000Z","published_at":"2019-11-12T08:49:31.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eCheck if integer i is a prime number. Returns logical true '1' if it is.\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\"}]}"},{"id":44645,"title":"Prime numbers between a , b.","description":"Find all prime number between a \u0026 b (including a and b).\r\nexample:\r\n\r\na=100\r\n\r\nb=120\r\n\r\ny= [101 103 107 109 113]","description_html":"\u003cp\u003eFind all prime number between a \u0026 b (including a and b).\r\nexample:\u003c/p\u003e\u003cp\u003ea=100\u003c/p\u003e\u003cp\u003eb=120\u003c/p\u003e\u003cp\u003ey= [101 103 107 109 113]\u003c/p\u003e","function_template":"function y = allprimes(a,b)\r\n  y = x;\r\nend","test_suite":"%%\r\na=100;\r\nb=120;\r\ny_correct =  [101 103 107 109 113];\r\nassert(isequal(allprimes(a,b),y_correct))\r\n%%\r\na=140;\r\nb=180;\r\ny_correct =  [149 151 157 163 167 173 179];\r\nassert(isequal(allprimes(a,b),y_correct))\r\n%%\r\na=14;\r\nb=20;\r\ny_correct =  [17 19];\r\nassert(isequal(allprimes(a,b),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":218677,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-18T19:45:06.000Z","updated_at":"2026-04-05T20:58:23.000Z","published_at":"2018-05-18T19:45:06.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eFind all prime number between a \u0026amp; b (including a and b). example:\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\u003ea=100\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\u003eb=120\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\u003ey= [101 103 107 109 113]\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\"}]}"},{"id":1673,"title":"Pandiagonal Prime Magic Square Verification","description":"Verify if an NxN matrix is a Pandiagonal Prime Magic Square.  \r\n\r\nRequired properties:\r\n\r\n  1) N^2 prime values ( No repeats, 1 is a non-prime )\r\n  2) Every row, column, diagonal, anti-diagonal, broken diagonals sum to same value\r\n3) Magic Constant is the sum of a row/column/diagonal\r\n\r\n\r\n*Input:* M  (Matrix NxN)\r\n\r\n*Output:* Magic Constant ( 0 if invalid )\r\n\r\n*Example:*\r\n\r\nm=[7 107 23 103;89 37 73 41;97 17 113 13;47 79 31 83]; Magic is 240\r\n\r\nRows;Columns; Diags 7+37+113+83, 107+73+13+47, 23+41+97+79, 103+89+17+31; \r\n\r\nAnti-Diag 103+73+17+47, 23+37+97+83, 107+89+13+31, 7+41+113+79\r\n\r\n*Related:*\r\n\r\n1) \u003chttp://www.mathworks.com/matlabcentral/cody/problems/1634-kurchan-square-evaluation-function Kurchan Evaluation\u003e has similar array processing\r\n\r\n2) Create Minimum Pandiagonal Prime Magic Squares (6:20) Bonus for 14","description_html":"\u003cp\u003eVerify if an NxN matrix is a Pandiagonal Prime Magic Square.\u003c/p\u003e\u003cp\u003eRequired properties:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1) N^2 prime values ( No repeats, 1 is a non-prime )\r\n2) Every row, column, diagonal, anti-diagonal, broken diagonals sum to same value\r\n3) Magic Constant is the sum of a row/column/diagonal\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e M  (Matrix NxN)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e Magic Constant ( 0 if invalid )\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003em=[7 107 23 103;89 37 73 41;97 17 113 13;47 79 31 83]; Magic is 240\u003c/p\u003e\u003cp\u003eRows;Columns; Diags 7+37+113+83, 107+73+13+47, 23+41+97+79, 103+89+17+31;\u003c/p\u003e\u003cp\u003eAnti-Diag 103+73+17+47, 23+37+97+83, 107+89+13+31, 7+41+113+79\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e1) \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/1634-kurchan-square-evaluation-function\"\u003eKurchan Evaluation\u003c/a\u003e has similar array processing\u003c/p\u003e\u003cp\u003e2) Create Minimum Pandiagonal Prime Magic Squares (6:20) Bonus for 14\u003c/p\u003e","function_template":"function MagicConstant = pandiag(m)\r\n MagicConstant=1;\r\nend\r\n","test_suite":"%%\r\nm=magic(20);\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,0))\r\n%%\r\nm=[41 137 149 19 37 6427 6343 6277 6449 6353 131 211 397 281 431 6421 6329 6197 6271 6199\r\n557 29 367 59 173 5923 6121 6101 6163 6287 643 827 929 947 769 5897 6043 5623 5851 5791\r\n419 571 631 853 919 6053 5801 5783 5573 5387 859 1229 857 1201 1487 5689 5419 5749 5393 5227\r\n1061 1103 1231 661 1093 5323 5381 5231 5189 5273 1847 2293 1499 2281 1867 4789 4243 5059 4889 4787\r\n1249 1277 1423 1889 1997 5051 4951 4931 4241 4373 2239 2309 2069 2731 2377 4481 4483 4597 4159 4273\r\n241 337 607 683 773 6311 6203 5987 5869 5857 151 263 359 421 379 6317 6217 6067 6047 6011\r\n1039 1301 1553 1697 1759 5501 5569 4999 5101 4801 953 503 991 809 1163 5527 5647 5477 5413 5297\r\n1471 2087 2003 1871 2357 5077 4561 4603 4723 4357 1031 1429 1777 1523 1789 5441 4943 4637 4903 4517\r\n2647 3823 2381 3709 3593 3989 2713 4177 3461 3061 1861 2633 2113 2089 2819 4523 3851 4349 3761 3547\r\n3373 3253 3323 3583 3259 3347 3539 3343 3307 3391 2383 2221 2677 2741 2879 3917 4007 3677 3389 3491\r\n6379 6299 6113 6229 6079 89 181 313 239 311 6469 6373 6361 6491 6473 83 167 233 61 157\r\n5867 5683 5581 5563 5741 613 467 887 659 719 5953 6481 6143 6451 6337 587 389 409 347 223\r\n5651 5281 5653 5309 5023 821 1091 761 1117 1283 6091 5939 5879 5657 5591 457 709 727 937 1123\r\n4663 4217 5011 4229 4643 1721 2267 1451 1621 1723 5449 5407 5279 5849 5417 1187 1129 1279 1321 1237\r\n4271 4201 4441 3779 4133 2029 2027 1913 2351 2237 5261 5233 5087 4621 4513 1459 1559 1579 2269 2137\r\n6359 6247 6151 6089 6131 193 293 443 463 499 6269 6173 5903 5827 5737 199 307 523 641 653\r\n5557 6007 5519 5701 5347 983 863 1033 1097 1213 5471 5209 4957 4813 4751 1009 941 1511 1409 1709\r\n5479 5081 4733 4987 4721 1069 1567 1873 1607 1993 5039 4423 4507 4639 4153 1433 1949 1907 1787 2153\r\n4649 3877 4397 4421 3691 1987 2659 2161 2749 2963 3863 2687 4129 2801 2917 2521 3797 2333 3049 3449\r\n4127 4289 3833 3769 3631 2593 2503 2833 3121 3019 3137 3257 3187 2927 3251 3163 2971 3167 3203 3119];\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,65100))\r\n%%\r\nm=[5 73 127 137 53\r\n37 167 17 71 103\r\n83 101 13 67 131\r\n43 31 197 113 11\r\n227 23 41 7 97];\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,395))\r\n%%\r\nm=[191\t89\t397\t409\t43\t157\t311\r\n379\t103\t101\t491\t17\t313\t193\r\n317\t241\t109\t163\t439\t47\t281\r\n223\t383\t227\t107\t541\t37\t79\r\n331\t337\t7\t139\t167\t563\t53\r\n83\t347\t389\t277\t127\t307\t67\r\n73\t97\t367\t11\t263\t173\t613];\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,1597))\r\n%%\r\nm=[191\t89\t397\t409\t43\t157\t311\r\n379\t103\t101\t491\t17\t313\t193\r\n317\t241\t109\t163\t439\t47\t281\r\n223\t383\t227\t107\t541\t37\t79\r\n331\t337\t7\t139\t167\t3\t53\r\n83\t347\t389\t277\t127\t307\t67\r\n73\t97\t367\t11\t263\t173\t613];\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,0))\r\n%%\r\nm=magic(7);\r\nMagicConstant=pandiag(m);\r\nassert(isequal(MagicConstant,0))\r\n\r\n\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":40,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-06-22T04:21:02.000Z","updated_at":"2026-03-02T16:07:10.000Z","published_at":"2013-06-22T06:02:47.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\u003eVerify if an NxN matrix is a Pandiagonal Prime Magic Square.\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\u003eRequired properties:\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[1) N^2 prime values ( No repeats, 1 is a non-prime )\\n2) Every row, column, diagonal, anti-diagonal, broken diagonals sum to same value\\n3) Magic Constant is the sum of a row/column/diagonal]]\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\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 M (Matrix NxN)\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 Magic Constant ( 0 if invalid )\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\u003em=[7 107 23 103;89 37 73 41;97 17 113 13;47 79 31 83]; Magic is 240\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\u003eRows;Columns; Diags 7+37+113+83, 107+73+13+47, 23+41+97+79, 103+89+17+31;\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\u003eAnti-Diag 103+73+17+47, 23+37+97+83, 107+89+13+31, 7+41+113+79\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\u003eRelated:\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\u003e1)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/1634-kurchan-square-evaluation-function\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eKurchan Evaluation\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e has similar array processing\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\u003e2) Create Minimum Pandiagonal Prime Magic Squares (6:20) Bonus for 14\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\"}]}"},{"id":60939,"title":"Frequencies of prime gaps","description":"Problem statement\r\n\r\nGiven two positive integers n and , write a function which computes the frequency of the gap   between two consecutive of the primes in the prime vector going from 2 to n.\r\n\r\nExamples\r\n\r\nFor n = 100 and = 2, your function should return f = 1/3 since one third of the prime gaps between 2 and 97 equal ;\r\nFor n = 1000 and = 6, your function should return f = 44/167;\r\n\r\n\r\nSee also\r\nProblem 60940. Find the first occurence of a given gap between two consecutive prime numbers\r\nPrime numbers properties II","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 414.733px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 207.367px; transform-origin: 408px 207.367px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63.0083px 8px; transform-origin: 63.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eProblem statement\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 21px; text-align: left; transform-origin: 385px 21px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 85.575px 8px; transform-origin: 85.575px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven two positive integers \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 5.83333px 8px; transform-origin: 5.83333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 11.675px 8px; transform-origin: 11.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 180.475px 8px; transform-origin: 180.475px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ewrite a function which computes the frequency of the gap  \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 81.7833px 8px; transform-origin: 81.7833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e between two consecutive of the primes in the prime vector going from \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e2\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 9.71667px 8px; transform-origin: 9.71667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 32.675px 8px; transform-origin: 32.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExamples\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 81.7333px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 40.8667px; transform-origin: 392px 40.8667px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 12.4417px 8px; transform-origin: 12.4417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.4833px 8px; transform-origin: 25.4833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en = 100 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 9.925px 8px; transform-origin: 9.925px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e= 2\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 86.7417px 8px; transform-origin: 86.7417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, your function should return\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.5833px 8px; transform-origin: 21.5833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e f = 1/3\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 133.808px 8px; transform-origin: 133.808px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e since one third of the prime gaps between \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e2\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 9.725px 8px; transform-origin: 9.725px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 97\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.0083px 8px; transform-origin: 21.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e equal \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 55.4333px 8px; transform-origin: 55.4333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor n = 1000 and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: normal; font-weight: 400; color: rgb(0, 0, 0);\"\u003eΔ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 9.925px 8px; transform-origin: 9.925px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e= 6\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 86.7417px 8px; transform-origin: 86.7417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, your function should return\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.8583px 8px; transform-origin: 11.8583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e f = \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 9.725px 8px; transform-origin: 9.725px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e44/\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e167;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.3917px 8px; transform-origin: 28.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eSee also\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/problems/60940-find-the-first-occurence-of-a-given-gap-between-two-consecutive-prime-numbers\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 60940. Find the first occurence of a given gap between two consecutive prime numbers\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/groups/95759\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ePrime numbers properties II\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function f = frequencies_of_prime_gaps(delta, n)\r\n  f = delta*n;\r\nend","test_suite":"%%\r\ndelta = 2;\r\nn = 100;\r\nf_correct = 1/3;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 2;\r\nn = 200;\r\nf_correct = 15/45;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 6;\r\nn = 1000;\r\nf_correct = 44/167;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 4;\r\nn = 200;\r\nf_correct = 13/45;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 24;\r\nn = 10000;\r\nf_correct = 15/1228;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 1;\r\nn = 100;\r\nf_correct = 1/24;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%%\r\ndelta = 3;\r\nn = 100;\r\nf_correct = 0;\r\nfrequencies_of_prime_gaps(delta,n)\r\nassert(isequal(frequencies_of_prime_gaps(delta,n),f_correct))\r\n\r\n%% Forbidden functions\r\nfiletext = fileread('frequencies_of_prime_gaps.m');\r\nillegal = contains(filetext, 'regexp') || contains(filetext, 'str2num') || contains(filetext, 'assignin') || contains(filetext, 'echo')\r\nassert(~illegal);","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":149128,"edited_by":149128,"edited_at":"2025-07-26T06:48:50.000Z","deleted_by":null,"deleted_at":null,"solvers_count":27,"test_suite_updated_at":"2025-07-09T05:56:16.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2025-06-24T10:21:21.000Z","updated_at":"2026-03-16T13:25:01.000Z","published_at":"2025-06-24T11:07:25.000Z","restored_at":null,"restored_by":null,"spam":null,"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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eProblem statement\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\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\u003eGiven two positive integers \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ewrite a function which computes the frequency of the gap  \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e between two consecutive of the primes in the prime vector going from \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en = 100 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e= 2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, your function should return\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = 1/3\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e since one third of the prime gaps between \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 97\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e equal \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor n = 1000 and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e= 6\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, your function should return\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e44/\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e167;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSee also\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/problems/60940-find-the-first-occurence-of-a-given-gap-between-two-consecutive-prime-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 60940. Find the first occurence of a given gap between two consecutive prime numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/groups/95759\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePrime numbers properties II\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":42317,"title":"De-primed","description":"Write a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.","description_html":"\u003cp\u003eWrite a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.\u003c/p\u003e","function_template":"function [M] = de_primed(M)\r\n\r\nM = M;\r\n\r\nend\r\n","test_suite":"%%\r\nM = 1:10;\r\nM_corr = [2,4,6,4,10,6,14,8,9,10];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\nM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\nM_corr = [4 M(2:end)];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 10:10:100;\r\nM_corr = M;\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 3:3:100;\r\nM_corr = [6,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\nM_corr = 2*M;\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = magic(6);\r\nM_corr = [35, 2, 6,26,38,24;\r\n           6,32,14,21,46,25;\r\n          62, 9, 4,22,27,20;\r\n           8,28,33,34,10,15;\r\n          30,10,34,12,14,16;\r\n           4,36,58,26,18,22];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\n\tcase 2\r\n\t\tM = eye(4);\r\n\t\tM_corr = 2*M;\r\n\tcase 3\r\n\t\tM = 10:10:100;\r\n\t\tM_corr = M;\r\n\tcase 4\r\n\t\tM = magic(6);\r\n\t\tM_corr = [35, 2, 6,26,38,24;\r\n           6,32,14,21,46,25;\r\n          62, 9, 4,22,27,20;\r\n           8,28,33,34,10,15;\r\n          30,10,34,12,14,16;\r\n           4,36,58,26,18,22];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 3:3:100;\r\n\t\tM_corr = [6,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99];\r\n\tcase 2\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\n\tcase 3\r\n\t\tM = eye(4);\r\n\t\tM_corr = 2*M;\r\n\tcase 4\r\n\t\tM = 20:3:50;\r\n\t\tM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 20:3:50;\r\n\t\tM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\n\tcase 2\r\n\t\tM = 10:10:100;\r\n\t\tM_corr = M;\r\n\tcase 3\r\n\t\tM = 2:2:100;\r\n\t\tM_corr = [4 M(2:end)];\r\n\tcase 4\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":171,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-17T01:45:02.000Z","updated_at":"2026-03-11T18:31:28.000Z","published_at":"2015-05-17T01:45:02.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eWrite a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.\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\"}]}"},{"id":44699,"title":"Prime Product","description":"My professor has given a sequence of N numbers as a1, a2, ..., aN and asked me to find the smallest possible value of ai * aj such that it is a prime number, where 1 \u003c= i \u003c j \u003c= N.\r\n\r\nIf it's possible to find any value of ai * aj such that it is a prime number, then print the smallest value of such ai * aj, otherwise print -1.\r\n\r\n  x=[1 2 3]\r\ny = 2\r\n\r\n\r\n  x=[5 5 5 2]\r\ny = -1\r\n","description_html":"\u003cp\u003eMy professor has given a sequence of N numbers as a1, a2, ..., aN and asked me to find the smallest possible value of ai * aj such that it is a prime number, where 1 \u0026lt;= i \u0026lt; j \u0026lt;= N.\u003c/p\u003e\u003cp\u003eIf it's possible to find any value of ai * aj such that it is a prime number, then print the smallest value of such ai * aj, otherwise print -1.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex=[1 2 3]\r\ny = 2\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003ex=[5 5 5 2]\r\ny = -1\r\n\u003c/pre\u003e","function_template":"function y = prime_product(x)\r\n  % my first problem I created\r\nend","test_suite":"%%\r\nx = [1 2 3];\r\ny_correct = 2;\r\nassert(isequal(prime_product(x),y_correct))\r\n\r\n%%\r\nx = [5 2 5 2];\r\ny_correct = -1;\r\nassert(isequal(prime_product(x),y_correct))\r\n\r\n%%\r\nx = [1 63];\r\ny_correct = -1;\r\nassert(isequal(prime_product(x),y_correct))\r\n\r\n%% \r\nx = [ 3 6 234 1 623 234 ];\r\ny_correct = 3;\r\nassert(isequal(prime_product(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":195572,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":34,"test_suite_updated_at":"2018-07-30T18:29:12.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-07-18T20:13:31.000Z","updated_at":"2025-12-09T15:21:32.000Z","published_at":"2018-07-18T20:40:31.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\u003eMy professor has given a sequence of N numbers as a1, a2, ..., aN and asked me to find the smallest possible value of ai * aj such that it is a prime number, where 1 \u0026lt;= i \u0026lt; j \u0026lt;= 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\u003eIf it's possible to find any value of ai * aj such that it is a prime number, then print the smallest value of such ai * aj, otherwise print -1.\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[x=[1 2 3]\\ny = 2\\n\\nx=[5 5 5 2]\\ny = -1]]\u003e\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\"}]}"},{"id":54119,"title":"Create the Ulam spiral","description":"Have you ever seen this wonderful spiral ? The Ulam Spiral is arranging prime numbers in a clockwise spiral starting in 0.\r\nGiven an n by n matrix of 0s, fill it with 1 if the number is prime, in that order : \r\n[7 8 9;\r\n 6 1 2;\r\n 5 4 3;]\r\n\r\nWhich will give you :\r\n[1 0 0;\r\n 0 0 1;\r\n 1 0 1;]\r\n\r\nAs you experiment, look out for the strange patterns that emerge!\r\n","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 381px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 190.5px; transform-origin: 407px 190.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 379px 8px; transform-origin: 379px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHave you ever seen this wonderful spiral ? The Ulam Spiral is arranging prime numbers in a clockwise spiral starting in 0.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 242.5px 8px; transform-origin: 242.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven an n by n matrix of 0s, fill it with 1 if the number is prime, in that order : \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e[7 8 9;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e 6 1 2;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22px 8px; transform-origin: 22px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e 5 4 3;]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63px 8px; transform-origin: 63px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhich will give you :\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e[1 0 0;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e 0 0 1;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22px 8px; transform-origin: 22px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e 1 0 1;]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 206px 8px; transform-origin: 206px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAs you experiment, look out for the strange patterns that emerge!\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y= ulam_spiral(n)\r\n    y=zeros(n);\r\nend\r\n","test_suite":"%%\r\nx = 3;\r\ny_correct = [1 0 0; 0 0 1; 1 0 1];\r\nassert(isequal(ulam_spiral(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct =[0     0     1     0     0;     0     1     0     0     0;     1     0     0     1     1;     0     1     0     1     0;     1     0     0     0     1];\r\nassert(isequal(ulam_spiral(x),y_correct))\r\n%%\r\nx = 1;\r\nassert(isequal(ulam_spiral(x),~x))\r\n%%\r\nx = 2;\r\ny_correct = [0 1; 0 1];\r\nassert(isequal(ulam_spiral(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":2001505,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2022-03-05T06:01:52.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-03-04T19:34:20.000Z","updated_at":"2022-03-05T06:01:52.000Z","published_at":"2022-03-04T19:34:20.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\u003eHave you ever seen this wonderful spiral ? The Ulam Spiral is arranging prime numbers in a clockwise spiral starting in 0.\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\u003eGiven an n by n matrix of 0s, fill it with 1 if the number is prime, in that order : \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\u003e[7 8 9;\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\u003e 6 1 2;\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\u003e 5 4 3;]\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\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 will give you :\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\u003e[1 0 0;\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\u003e 0 0 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\u003e 1 0 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\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\u003eAs you experiment, look out for the strange patterns that emerge!\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\u003e\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":45794,"title":"*Prime number check 2 (in construction)","description":"Another way to see if a number is prime is to count the number of factors. For example,\r\n\r\n  the number 4 has 2 factors, [ 2 4 ]\r\n  the number 16 has 4 factors, [ 2 4 8 16 ]\r\n  the number 7 has 1 factor, [ 7 ]\r\n\r\nThus, if a number has only one factor, it is prime. We ignore the factor 1 as it is trivial. \r\n\r\nYour function should create a vector containing all the factors of any number x.","description_html":"\u003cp\u003eAnother way to see if a number is prime is to count the number of factors. For example,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ethe number 4 has 2 factors, [ 2 4 ]\r\nthe number 16 has 4 factors, [ 2 4 8 16 ]\r\nthe number 7 has 1 factor, [ 7 ]\r\n\u003c/pre\u003e\u003cp\u003eThus, if a number has only one factor, it is prime. We ignore the factor 1 as it is trivial.\u003c/p\u003e\u003cp\u003eYour function should create a vector containing all the factors of any number x.\u003c/p\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 16;\r\ny_correct = [ 2 4 8 16 ];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 23;\r\ny_correct = [ 23 ];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 100;\r\ny_correct = [ 2 4 5 10 20 25 50 100 ];\r\nassert(isequal(your_fcn_name(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":428668,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-06-07T20:00:06.000Z","updated_at":"2025-08-03T17:44:27.000Z","published_at":"2020-06-07T20:00:06.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\u003eAnother way to see if a number is prime is to count the number of factors. For example,\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[the number 4 has 2 factors, [ 2 4 ]\\nthe number 16 has 4 factors, [ 2 4 8 16 ]\\nthe number 7 has 1 factor, [ 7 ]]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThus, if a number has only one factor, it is prime. We ignore the factor 1 as it is trivial.\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\u003eYour function should create a vector containing all the factors of any number x.\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\"}]}"},{"id":45342,"title":"Sieve of Eratosthenes","description":"Find the nth lucky prime number.\r\n\r\n\u003chttps://planetmath.org/luckyprime\u003e\r\n\r\ncan u find a way for large n?","description_html":"\u003cp\u003eFind the nth lucky prime number.\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://planetmath.org/luckyprime\"\u003ehttps://planetmath.org/luckyprime\u003c/a\u003e\u003c/p\u003e\u003cp\u003ecan u find a way for large n?\u003c/p\u003e","function_template":"function y = lucky_prime(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(lucky_prime(4),31))\r\n%%\r\nassert(isequal(lucky_prime(10),127))\r\n%%\r\nassert(isequal(lucky_prime(20),349))\r\n%%\r\nassert(isequal(lucky_prime(27),541))\r\n%%\r\nassert(isequal(lucky_prime(39),823))\r\n%%\r\nassert(isequal(lucky_prime(50),1123))\r\n%%\r\nassert(isequal(lucky_prime(60),1579))\r\n%%\r\nassert(isequal(lucky_prime(70),1987))\r\n%%\r\nassert(isequal(lucky_prime(90),2971))\r\n%%\r\nassert(isequal(lucky_prime(80),2473))\r\n%%\r\nassert(isequal(lucky_prime(200),9403))\r\n%%\r\nassert(isequal(lucky_prime(260),12799))\r\n%%\r\nassert(isequal(lucky_prime(440),25237))\r\n%%\r\nassert(isequal(lucky_prime(600),38461))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":"2020-04-02T00:55:41.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2020-02-18T19:05:49.000Z","updated_at":"2026-01-19T18:26:06.000Z","published_at":"2020-02-18T19:39:25.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\u003eFind the nth lucky prime number.\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:hyperlink w:docLocation=\\\"https://planetmath.org/luckyprime\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://planetmath.org/luckyprime\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\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\u003ecan u find a way for large 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\"}]}"},{"id":3016,"title":"Twin Primes","description":"Twin primes are pairs of primes that are immediately next to each other (difference of two). The lesser of twin primes are 3, 5, 11, 17, 29, ... ( \u003chttp://oeis.org/A001359 ref.\u003e ). The greater of twin primes are 5, 7, 13, 19, 31, ... ( \u003chttp://oeis.org/A006512 ref.\u003e ). Therefore, the first five twin primes are [3,5] [5,7] [11,13] [17,19] [29,31].\r\n\r\nFor a given index range n, return the twin primes corresponding to that range as a two-row column array.","description_html":"\u003cp\u003eTwin primes are pairs of primes that are immediately next to each other (difference of two). The lesser of twin primes are 3, 5, 11, 17, 29, ... ( \u003ca href = \"http://oeis.org/A001359\"\u003eref.\u003c/a\u003e ). The greater of twin primes are 5, 7, 13, 19, 31, ... ( \u003ca href = \"http://oeis.org/A006512\"\u003eref.\u003c/a\u003e ). Therefore, the first five twin primes are [3,5] [5,7] [11,13] [17,19] [29,31].\u003c/p\u003e\u003cp\u003eFor a given index range n, return the twin primes corresponding to that range as a two-row column array.\u003c/p\u003e","function_template":"function [twins] = twin_primes(n)\r\n\r\ntwins = n;\r\n\r\nend","test_suite":"%%\r\nn = 1:5;\r\ntwins_corr = [3, 5, 11, 17, 29; 5, 7, 13, 19, 31];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 1:10;\r\ntwins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 1:25;\r\ntwins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 1:51;\r\ntwins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641, 659, 809, 821, 827, 857, 881, 1019, 1031, 1049, 1061, 1091, 1151, 1229, 1277, 1289, 1301, 1319, 1427, 1451, 1481, 1487, 1607; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523, 571, 601, 619, 643, 661, 811, 823, 829, 859, 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231, 1279, 1291, 1303, 1321, 1429, 1453, 1483, 1489, 1609];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 10:29;\r\ntwins_corr = [107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641; 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523, 571, 601, 619, 643];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 2:8;\r\ntwins_corr = [5, 11, 17, 29, 41, 59, 71; 7, 13, 19, 31, 43, 61, 73];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 35:42;\r\ntwins_corr = [881, 1019, 1031, 1049, 1061, 1091, 1151, 1229; 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 34:47;\r\ntwins_corr = [857, 881, 1019, 1031, 1049, 1061, 1091, 1151, 1229, 1277, 1289, 1301, 1319, 1427; 859, 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231, 1279, 1291, 1303, 1321, 1429];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n\r\n%%\r\nn = 9:-1:4;\r\ntwins_corr = [101, 71, 59, 41, 29, 17; 103, 73, 61, 43, 31, 19];\r\nassert(isequal(twin_primes(n),twins_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":98,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":30,"created_at":"2015-02-14T03:03:50.000Z","updated_at":"2026-03-16T14:18:09.000Z","published_at":"2015-02-14T03:03:50.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\u003eTwin primes are pairs of primes that are immediately next to each other (difference of two). The lesser of twin primes are 3, 5, 11, 17, 29, ... (\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://oeis.org/A001359\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eref.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e ). The greater of twin primes are 5, 7, 13, 19, 31, ... (\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://oeis.org/A006512\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eref.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e ). Therefore, the first five twin primes are [3,5] [5,7] [11,13] [17,19] [29,31].\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\u003eFor a given index range n, return the twin primes corresponding to that range as a two-row column array.\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\"}]}"},{"id":42509,"title":"Divisible by n, Truncated-number Divisors","description":"Some divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\r\n\r\n* 25: The last two digits must be divisible by 25.\r\n* 32: The last five digits must be divisible by 32.\r\n* 50: The last two digits must be 00 or 50.\r\n* 64: The last six digits must be divisible by 64.\r\n* 75: The number must be divisible by 3 (can be done by a \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3 simple sum\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25). \r\n* 100: The last two digits must be 00.\r\n* 125: The last three digits must be divisible by 125.\r\n* 128: The last seven digits must be divisible by 128.\r\n* 256: The last eight digits must be divisible by 256.\r\n* 512: The last nine digits must be divisible by 512.\r\n\r\nThe only restriction that remains is Java.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200 Divisible by n, prime divisors from 20 to 200\u003e. Next problem \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors Divisible by n, Composite Divisors\u003e.","description_html":"\u003cp\u003eSome divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\u003c/p\u003e\u003cul\u003e\u003cli\u003e25: The last two digits must be divisible by 25.\u003c/li\u003e\u003cli\u003e32: The last five digits must be divisible by 32.\u003c/li\u003e\u003cli\u003e50: The last two digits must be 00 or 50.\u003c/li\u003e\u003cli\u003e64: The last six digits must be divisible by 64.\u003c/li\u003e\u003cli\u003e75: The number must be divisible by 3 (can be done by a \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3\"\u003esimple sum\u003c/a\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25).\u003c/li\u003e\u003cli\u003e100: The last two digits must be 00.\u003c/li\u003e\u003cli\u003e125: The last three digits must be divisible by 125.\u003c/li\u003e\u003cli\u003e128: The last seven digits must be divisible by 128.\u003c/li\u003e\u003cli\u003e256: The last eight digits must be divisible by 256.\u003c/li\u003e\u003cli\u003e512: The last nine digits must be divisible by 512.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe only restriction that remains is Java.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\"\u003eDivisible by n, prime divisors from 20 to 200\u003c/a\u003e. Next problem \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors\"\u003eDivisible by n, Composite Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = truncated_number_divisors(n,n_str)\r\n\r\ntf = 1;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('truncated_number_divisors.m');\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 25;\r\nn_str = '123456789025';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 25;\r\nn_str = '1234567890250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 25;\r\nn_str = '1234567890250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 32;\r\nn_str = '213546116579874651316984601654958847098406516051320150408460840649084790870510201378465465046760406541654604601561065140637860373703970644065166540616510650165409684098049804165016510320540540645106056501650165709804650860466840650156106165028224';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 32;\r\nn_str = '213546116579874651316984601654958847098406516051320150408460840649084790870510201378465465046760406541654604601561065140637860373703970644065166540616510650165409684098049804165016510320540540645106056501650165709804650860466840650156106165028227';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '15668045014654987098045406540500';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '50440984098480149540561065106510516501615001';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '50440984098480149540561065106510516501615001897241387234587503198417059813645097867234985672307485679813709582304957234897659832746098514949188412929894824924949334949777378994191995216173718811313515141418186186382171646871681436817897678350';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404996';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489216';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489217';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 75;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499175';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 75;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499275';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992750';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992700';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499200';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499200125';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489216';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111114892375';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 128;\r\nn_str = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111148923751048576';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 128;\r\nn_str = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111148923751048578';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 256;\r\nn_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678904049917516777216';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 256;\r\nn_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678904049917516777210';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000134217728';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000536870912';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000536870914';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-17T21:32:54.000Z","updated_at":"2026-01-11T10:42:54.000Z","published_at":"2015-08-17T21:32:54.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\u003eSome divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e25: The last two digits must be divisible by 25.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e32: The last five digits must be divisible by 32.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e50: The last two digits must be 00 or 50.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e64: The last six digits must be divisible by 64.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e75: The number must be divisible by 3 (can be done by a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esimple sum\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e100: The last two digits must be 00.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e125: The last three digits must be divisible by 125.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e128: The last seven digits must be divisible by 128.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e256: The last eight digits must be divisible by 256.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e512: The last nine digits must be divisible by 512.\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 only restriction that remains is Java.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors from 20 to 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Composite Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":60941,"title":"Prime numbers which are the difference of two consecutive cubes","description":"Problem statement\r\n\r\nGiven a positive integer n greater than 2, find the prime numbers less or equal to n and which are the difference of the cubes of two consecutive integers and store them in ascending order in a row vector u. Also, compute the frequency / ratio f of those numbers compare to all the prime numbers less or equal to n.\r\n\r\nExamples\r\n\r\nIf n = 100, then u = [7, 19, 37, 61], and f = 4/25, since 7 = 2^3 - 1^3, 19 = 3^3 - 2^3, 37 = 4^3 - 3^3, 61 = 5^3 - 4^3, and there are 25 prime numbers less or equal to 100;\r\nIf n = 400, then u = [7, 19, 37, 61, 127, 271, 331, 397], and f = 8/78, since 127 = 7^3 - 6^3, 271 = 10^3 - 9^3, 331 = 11^3 - 10^3, 397 = 12^3 - 11^3, and there are 78 prime numbers less or equal to 400;\r\nTips\r\n\r\n\r\n\r\nForbidden functions\r\n\r\nregexpr\r\nstr2num\r\nassignin\r\n\r\nSee also\r\nPrime numbers properties II","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 668.033px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 334.017px; transform-origin: 408px 334.017px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63.0083px 8px; transform-origin: 63.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eProblem statement\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 31.5px; text-align: left; transform-origin: 385px 31.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 75.075px 8px; transform-origin: 75.075px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a positive integer \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 5.83333px 8px; transform-origin: 5.83333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 37.7333px 8px; transform-origin: 37.7333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003egreater than\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 9.71667px 8px; transform-origin: 9.71667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 2, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 122.917px 8px; transform-origin: 122.917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003efind the prime numbers less or equal to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 129.833px 8px; transform-origin: 129.833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and which are the difference of the cubes of two consecutive integers and store them in ascending order in a row vector \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eu\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 113.95px 8px; transform-origin: 113.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Also, compute the frequency / ratio \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ef\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 9.71667px 8px; transform-origin: 9.71667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e of those numbers compare to all the prime numbers less or equal to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 32.675px 8px; transform-origin: 32.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExamples\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 81.7333px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 40.8667px; transform-origin: 392px 40.8667px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 6.21667px 8px; transform-origin: 6.21667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eIf \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 27.8083px 8px; transform-origin: 27.8083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003en = 100, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 14.775px 8px; transform-origin: 14.775px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ethen\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 61.6333px 8px; transform-origin: 61.6333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e u = [7, 19, 37, 61], \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 12.4417px 8px; transform-origin: 12.4417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.8667px 8px; transform-origin: 25.8667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e f = 4/25\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 16.3417px 8px; transform-origin: 16.3417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 190.017px 8px; transform-origin: 190.017px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 7 = 2^3 - 1^3, 19 = 3^3 - 2^3, 37 = 4^3 - 3^3, 61 = 5^3 - 4^3, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 41.625px 8px; transform-origin: 41.625px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand there are\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.6667px 8px; transform-origin: 11.6667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 25 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 96.0833px 8px; transform-origin: 96.0833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eprime numbers less or equal to\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 100;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 6.21667px 8px; transform-origin: 6.21667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eIf \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 27.8083px 8px; transform-origin: 27.8083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003en = 400, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 14.775px 8px; transform-origin: 14.775px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ethen\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 123.867px 8px; transform-origin: 123.867px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e u = [7, 19, 37, 61, 127, 271, 331, 397], \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 12.4417px 8px; transform-origin: 12.4417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.8667px 8px; transform-origin: 25.8667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e f = 8/78\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 16.3417px 8px; transform-origin: 16.3417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 129.25px 8px; transform-origin: 129.25px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 127 = 7^3 - 6^3, 271 = 10^3 - 9^3, 331 = 11^3 - 10^3, 397 = 12^3 - 11^3, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 41.625px 8px; transform-origin: 41.625px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand there are\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.6667px 8px; transform-origin: 11.6667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 78 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 96.0833px 8px; transform-origin: 96.0833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eprime numbers less or equal to\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e 400;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14.2583px 8px; transform-origin: 14.2583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eTips\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWAAAAAnCAYAAAAxS5IsAAAKO0lEQVR4Xu2dW8h2QxTHfffkdMUFwgXlVI4RF3IokSRn6S1yuJAUiiQXQijJhUPoS5JDLkSKRBE5JIeICwoXXBFxz/rVs7JMe78zs/fs2bP3t3atvsOznzn8Z81/rVlrZp4du/njCDgCjoAjMAsCO2ap1St1BBwBR8AR2M0J2JXAEXAEHIGZEHACngl4r9YRcAQcASdg1wFHwBFwBGZCwAm4PvD7SJWPiZwjsrvI3yLXiLxYvymT13i81HCPyFmbmr6TP68S+XTympdbgWJ28kY/fpU/b16pfix3lAq1PJeAIY/rRO4rVP8airleOvGSyO+JnflW3vtK5GmRg0Ue3Ey0s+XPtxLLWMJrh0gj3xd5TuRtkTNEbt00PFfvltDfEm2EfF8VeVTkM5ELRa7dFIye3FaiEi+jHQRyJgLk+4bIjSLuwfw3hkwaJkwKLpA1pGsnEv+HR/ykCMZtLQ8ePUbGGhX+72KRS0XW6PGPHbs3pYBnAmxul3/fK8JKaY+xFfj320IglYAh3w9EfPnYPX7quZwfMU6894OI9ZZZnjPx7hBZ08qCfoUe/QPyf3jBJ0RwamuW1GvNR1IVoSmrH8y93zZN2Df4rF7LvKZJEEglYBTjPZFdaQnEEhrPYy8RwgOxB8J5ROSUzEkCKZ034Hux9rT4OXr0k8glLTaup02M69Uip4rsJ4In+qHInSK1VoL/SF3Ego/I1K2aMLeAU83+blcXq9q7RGIOWdI+YAjiSpH9W+ndxO1Q4mWpzIMXl0LAvIsn+6NIaigBpd2ZMlAT97lG8SylWUHlGqgabeurQ8NDkN/PIgeIQML61AiloI/fZ+phbcxawKl2n7vqU+JVHYmu9GIeMMsfPBaWjY+30MOJ2wBJHCOC16uZ+xwC1skSS6gRirhFREmebh0qQnhibQ/eLln8Ezcdg8yWYMxp98MixPdtaAi9eEWEHSw1+sKkJgF3ukgtjztHB1vBKafNpd9lPrOTiefyjW7w99EE3Kr3i1JuiZQOi0CgSoIs+3hyCJj3WWb/KZLiNWvY4jB5/2ORk0prRkPlKZFAXEvI6LNbpS/noYmxpEk2cgx+ke+zk6RU+O8JKetoEYxLiURoKzilwsz85LnCzPXU7/a9Z3lD8xxJuhHzgP+SUp4XSV1Sj+1I6ve1k7nkmFo+7w0lYF2OpXq0rDK+FmHZEhuPnPa3+C6ewicirRsbDOOxIn1JUU2cEg+e0jNFzw8UuUEkdZtjbNwhIFYjJZK+reAU67P9XOd11DvNKdS8W4yAWVq8IFIjzpXb15YJWMMQOQqu/dkVstwQwJ4ih+cOekPv69zgYMlU/dDQTbgrYiwMJQk41pYaOMXaEH6+GAJmqcIm8BZJoWUCZsBZOZApTwlD8L7vhMidRvO+z9IdYpzqBKPuLS+5TFbEahLw1DgN0YLFELAOVGxZjLJwuIAl22kiZIq3RAgPhMduOTFWYgtS6wQMduCQmmzi/S9FWgv14M0jnGIjbkifXhPReKTmCAif4A3GdjhoUncq4hoyIXO/o5nuvuPB9PG4zXwgoUsIgUfj++j/3SLE/btCGLqnnG1vYVIWQhsbjqhFwFPjlDtu+v5iCBgv7hujOH0dJiFxkIgemdT9ikzcd0Q4PXfURuEoI7ZDIAXYJRAwcbbQeDGBmFh28qKoN4mc2zHhUrCY8h3IAsPKpCd5xkPsDGLgYA7JRkR3jNjkGskjtm7ZE4Ka9MklEZ00Y/o6Nl8AsRITVj3HmejqBwR6kQh7uyFZHg1H6fhjxLQcGw9nznwhwrwjwWwfnJsSRnpqAq6B0xg9WAwB09CcZIl2DMV8SIQz7VsiKH5WYDoB3dYJWNsXJuIwVkxG3cLERPxcJOcuiQR4ir+ikxYvF0PxusizIhCSJqQs0fB3PXbM39EjyAODPCTzPicBh/vCLbh4sHi5XdsHrc6jBxzq4VHSDpO8etpUSbtrEEskjqYi4Fo4jVXuVRKwnYQk7e7eiE42nYwpy9QUgJdCwCW8/RQ8pn5HlRYPlyX1HyIaLtFdH7QhdefH1O2dqnz1bu2KoC8Rp0SH8dkpsiWiCTVN1Coh19xjPxUBW8xbxmmVBKyEqMc0fzQTlIFhryCWPTUGbAl9zGTK2YkQ1jN0GxrlKB5TEHAJbHKW47Y+xg8Ctpl5TdaWMq5jxrvWdzVUYMMy4SEJqz9HSsNsTFd3B0xhtKznPQaPEt72HDipgRnT9zEXH2Wt9rdLsOWEIJRg6TQW305Qa+1Tt7SVIBnaMhcBT7mDpAQ2OQSsfQHPriU3sV6ScGu7zS02ga3nH+qZJVjKCfXerghLb2NriYDpe22cVkPAmkSJnc6ytzUBeGg5dQCYvHhPJTaUtx6CSN1BEpvkLXxujWtINNa4TuHtt9D/vjZYvQ9xsUary9ip0ZrjRGCNEITFrDWcFhOCSCURa+G6vCC19jkJvdjEWwIBL/2wAWNgCTZc2VjvpqRx7Rr7OZNw2+mitis0PkqwXSuGuY1WbQIGv5ZwWgwB92XyQ4W02e6uuBHb2YiVjQkHhHW2TsAMcmq8O2Zs5vx8u+Uj7eL2N0IiOSGNIf1pkYDVswuvibQE24WL3iMx1/WStQm4NZwWQ8B6bj8Wt1WC7fJwtQwbmmB5NvbAQcsErH0mU14zuz2E2GLfUYLt83BD4wq5YHjWeKtbiJUapzCMYC/q6QrLhEYLA7a3yJDtebHx6/q8NgG3htNiCJjBYynF73r1nV6zBNvl4YYZcn56h+stx97s1DIB0zbIt1S8e8gkK/UdJdguTy7M5J8plV4gcplIiTh/qT4MKUePAnPIpOvidT5nT3PXQSUl2C4P18ZD0RF+94391DUP4ZQk4CXitCgCjpGJtfZde0B1sHV7GvtHc09BdU2gqQnY7jTIvXAlZrSGEMIc37HGtcubt9l2vF5OO9YkkikxsXpNPfSP37fj4WQgp/s4RMN7obFRo9UVgrJ6hVFje9qWSPjTTVP2rSQBLxGnqQnY7sKIRQ+i1x/GLmS3J6S67gFQLwkCxvu9v0NhhyjbVATMcgkvTo/WatvwZriT9WWR7S7F5ntc1t13OmpIX+f6TniSKwwr2D2ekA0roLWEHsI7TBgD/VUMTnj2hVkswfaFoHRXCSE7framJvnSj5IEvEScpiBg5gKreo6f219MAW90hePlnVebxi7aoQBI9CmRlpbUEOWWSImz8SUJjsllL6spWbaX5QiUQEAvZN8phS09RzEEDwwQT8qvmA8pP+s7KQRMgZogKHGTWVYDF/QyHiMXpsT2TS+oS95UR8ARmBKBVAKmDViOXdVqxsaApeeQX0SOleufOwKOwIoRyCFg9YTf3UWXLn1qoJlge/x6xSrjXXMEHIFSCOQSMPUShqi1Z7FUP6csx/GYEl0v2xFYMQJDCHjFcHjXHAFHwBGoh4ATcD2svSZHwBFwBP6HgBOwK4Qj4Ag4AjMh4AQ8E/BerSPgCDgCTsCuA46AI+AIzITAv+XNK1XoyvVEAAAAAElFTkSuQmCC\" width=\"176\" height=\"19.5\" style=\"width: 176px; height: 19.5px;\"\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 67.6417px 8px; transform-origin: 67.6417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eForbidden functions\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 30.65px; transform-origin: 392px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 23.7333px 8px; transform-origin: 23.7333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eregexpr\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.2833px 8px; transform-origin: 25.2833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003estr2num\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.6833px 8px; transform-origin: 25.6833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eassignin\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.3917px 8px; transform-origin: 28.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eSee also\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/groups/95759\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ePrime numbers properties II\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [u, f] = cube_delta_primes(n)\r\n  \r\n    u = n;\r\n    f = 1;\r\n\r\nend","test_suite":"%%\r\nn = 100;\r\nu_correct = [7, 19, 37, 61];\r\nf_correct = 4/25;\r\n[u,f] = cube_delta_primes(n);\r\nassert(isequal([u,f],[u_correct,f_correct]));\r\n\r\n%%\r\nn = 400;\r\nu_correct = [7, 19, 37, 61, 127, 271, 331, 397];\r\nf_correct = 8/78;\r\n[u,f] = cube_delta_primes(n);\r\nassert(isequal([u,f],[u_correct,f_correct]));\r\n\r\n%% Forbidden functions\r\nfiletext = fileread('cube_delta_primes.m');\r\nillegal = contains(filetext, 'regexp') || contains(filetext, 'str2num') || contains(filetext, 'assignin') || contains(filetext, 'echo')\r\nassert(~illegal);","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":149128,"edited_by":149128,"edited_at":"2025-07-26T06:46:51.000Z","deleted_by":null,"deleted_at":null,"solvers_count":30,"test_suite_updated_at":"2025-07-09T05:55:53.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2025-06-26T11:57:42.000Z","updated_at":"2026-03-30T01:16:24.000Z","published_at":"2025-06-26T12:34:41.000Z","restored_at":null,"restored_by":null,"spam":null,"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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eProblem statement\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\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\u003eGiven a positive integer \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003egreater than\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 2, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003efind the prime numbers less or equal to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and which are the difference of the cubes of two consecutive integers and store them in ascending order in a row vector \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eu\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Also, compute the frequency / ratio \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of those numbers compare to all the prime numbers less or equal to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eIf \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en = 100, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e u = [7, 19, 37, 61], \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = 4/25\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003esince\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 7 = 2^3 - 1^3, 19 = 3^3 - 2^3, 37 = 4^3 - 3^3, 61 = 5^3 - 4^3, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand there are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 25 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eprime numbers less or equal to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 100;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eIf \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en = 400, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e u = [7, 19, 37, 61, 127, 271, 331, 397], \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = 8/78\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003esince\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 127 = 7^3 - 6^3, 271 = 10^3 - 9^3, 331 = 11^3 - 10^3, 397 = 12^3 - 11^3, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand there are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 78 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eprime numbers less or equal to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e 400;\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTips\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"true\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e(n+1)^3 - n^3 = 3n^2 + 3n + 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eForbidden functions\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexpr\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estr2num\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassignin\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSee also\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/groups/95759\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePrime numbers properties II\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":896,"title":"Sophie Germain prime","description":"In number theory, a prime number p is a *Sophie Germain prime* if 2p + 1 is also prime. For example, 23 is a Sophie Germain prime because it is a prime and 2 × 23 + 1 = 47, and 47 is also a prime number. These numbers are named after French mathematician Marie-Sophie Germain.\r\n\r\nSee \u003chttp://en.wikipedia.org/wiki/Sophie_Germain_prime Sophie Germain prime\u003e article on Wikipedia.\r\n\r\n\r\nIn this Problem , the input is a number and you must return true or false if this number is a Sophie Germain prime.","description_html":"\u003cp\u003eIn number theory, a prime number p is a \u003cb\u003eSophie Germain prime\u003c/b\u003e if 2p + 1 is also prime. For example, 23 is a Sophie Germain prime because it is a prime and 2 × 23 + 1 = 47, and 47 is also a prime number. These numbers are named after French mathematician Marie-Sophie Germain.\u003c/p\u003e\u003cp\u003eSee \u003ca href=\"http://en.wikipedia.org/wiki/Sophie_Germain_prime\"\u003eSophie Germain prime\u003c/a\u003e article on Wikipedia.\u003c/p\u003e\u003cp\u003eIn this Problem , the input is a number and you must return true or false if this number is a Sophie Germain prime.\u003c/p\u003e","function_template":"function tf = your_fcn_name(x)\r\n  tf = true;\r\nend","test_suite":"%%\r\np = 233;\r\ny_correct = true;\r\nassert(isequal(your_fcn_name(p),y_correct))\r\n\r\n%%\r\np = 23;\r\ny_correct14 = true;\r\nassert(isequal(your_fcn_name(p),y_correct14))\r\n\r\n%%\r\np = 22;\r\ny_correct14 = false;\r\nassert(isequal(your_fcn_name(p),y_correct14))\r\n\r\n%% \r\np = 1 % p must also be a prime number !!\r\ny_correct1t = false;\r\nassert(isequal(your_fcn_name(p),y_correct1t))\r\n\r\n%% \r\np = 14 % p must also be a prime number !!\r\ncorrect1t = false;\r\nassert(isequal(your_fcn_name(p),correct1t))\r\n\r\n%% \r\np = 29 \r\ncorrect1tp = true;\r\nassert(isequal(your_fcn_name(p),correct1tp))\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":2,"created_by":639,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1066,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":44,"created_at":"2012-08-10T13:04:11.000Z","updated_at":"2026-04-09T08:16:22.000Z","published_at":"2012-08-10T13:04:11.000Z","restored_at":"2018-10-10T14:57:27.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eIn number theory, a prime number p is a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSophie Germain prime\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e if 2p + 1 is also prime. For example, 23 is a Sophie Germain prime because it is a prime and 2 × 23 + 1 = 47, and 47 is also a prime number. These numbers are named after French mathematician Marie-Sophie Germain.\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\u003eSee\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Sophie_Germain_prime\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSophie Germain prime\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e article on Wikipedia.\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\u003eIn this Problem , the input is a number and you must return true or false if this number is a Sophie Germain prime.\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\"}]}"},{"id":42454,"title":"Divisible by n, prime divisors (including powers)","description":"For this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\r\n\r\n  n = 1:10;\r\n  n_p = [2 3 4 5 7 8 9];\r\n\r\nSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e.","description_html":"\u003cp\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1:10;\r\nn_p = [2 3 4 5 7 8 9];\r\n\u003c/pre\u003e\u003cp\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_p] = prime_divisors_incl_powers(n)\r\n\r\nn_p = 1;\r\n\r\nend","test_suite":"%%\r\nn = 1:10;\r\nn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = [2:7 12:17 10 42:55 11 19:29];\r\nn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1:100;\r\nn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 41:59;\r\nn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 100:200;\r\nn_p = [101 103 107 109 113 121 125 127 128 131 137 139 149 151 157 163 167 169 173 179 181 191 193 197 199]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1000:1111;\r\nn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:10;\r\n\t\tn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 3\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\n\tcase 3\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = 1000:1111;\r\n\t\tn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":95,"test_suite_updated_at":"2017-03-20T19:03:08.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:55:28.000Z","updated_at":"2026-01-11T12:28:45.000Z","published_at":"2015-07-09T01:55:28.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\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\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[n = 1:10;\\nn_p = [2 3 4 5 7 8 9];]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":3001,"title":"Sphenic number sequence","description":"Sphenic numbers are positive integers that are products of three distinct prime numbers: 30, 42, 66, 70, 78, 102, 105, 110, 114, 130, ... For example, 30 = 2*3*5, 42 = 2*3*7, etc.\r\nReturn the numbers from the sphenic sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [66, 70, 78, 102, 105].\r\nThis problem is related to Problem 3002 and Problem 3003.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 123px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.5px; transform-origin: 407px 61.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eSphenic numbers\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 317.5px 8px; transform-origin: 317.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e are positive integers that are products of three distinct prime numbers: 30, 42, 66, 70, 78, 102, 105, 110, 114, 130, ... For example, 30 = 2*3*5, 42 = 2*3*7, etc.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 365px 8px; transform-origin: 365px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn the numbers from the sphenic sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [66, 70, 78, 102, 105].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 80px 8px; transform-origin: 80px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem is related to\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3002-not-square-free-number-sequence\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3002\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14px 8px; transform-origin: 14px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3003-mobius-function\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3003\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [arr] = sphenic_seq(n)\r\n\r\narr = n;\r\n\r\nend","test_suite":"%%\r\nn = 1:5;\r\narr_corr = [30, 42, 66, 70, 78];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 1:10;\r\narr_corr = [30, 42, 66, 70, 78, 102, 105, 110, 114, 130];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 3:7;\r\narr_corr = [66, 70, 78, 102, 105];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 20:30;\r\narr_corr = [222   230   231   238   246   255   258   266   273   282   285];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 69;\r\narr_corr = 582;\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%%\r\nn = 1:53;\r\narr_corr = [30, 42, 66, 70, 78, 102, 105, 110, 114, 130, 138, 154, 165, 170, 174, 182, 186, 190, 195, 222, 230, 231, 238, 246, 255, 258, 266, 273, 282, 285, 286, 290, 310, 318, 322, 345, 354, 357, 366, 370, 374, 385, 399, 402, 406, 410, 418, 426, 429, 430, 434, 435, 438];\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n\r\n%% prevents cheating\r\ni1 = randi(20,1);\r\nn = i1:(i1+randi(25,1));\r\narr_tot = [30, 42, 66, 70, 78, 102, 105, 110, 114, 130, 138, 154, 165, 170, 174, 182, 186, 190, 195, 222, 230, 231, 238, 246, 255, 258, 266, 273, 282, 285, 286, 290, 310, 318, 322, 345, 354, 357, 366, 370, 374, 385, 399, 402, 406, 410, 418, 426, 429, 430, 434, 435, 438];\r\narr_corr = arr_tot(n);\r\nassert(isequal(sphenic_seq(n),arr_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":223089,"edited_at":"2022-10-09T05:23:45.000Z","deleted_by":null,"deleted_at":null,"solvers_count":87,"test_suite_updated_at":"2022-10-09T05:23:45.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-02-11T02:19:47.000Z","updated_at":"2026-03-16T14:15:22.000Z","published_at":"2015-02-11T02:19:47.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:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSphenic numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e are positive integers that are products of three distinct prime numbers: 30, 42, 66, 70, 78, 102, 105, 110, 114, 130, ... For example, 30 = 2*3*5, 42 = 2*3*7, etc.\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\u003eReturn the numbers from the sphenic sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [66, 70, 78, 102, 105].\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 problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3002-not-square-free-number-sequence\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3002\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3003-mobius-function\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3003\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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":60944,"title":"Ulam primes first formula","description":"Historical context\r\n\r\n\r\nThe polish-american mathematician Stanislaw Ulam found the formula  to give the first 760 prime numbers not given by Euler's formula. \r\n\r\n\r\nProblem statement\r\n\r\nFor a given integer m, m \u003e= 1847, list the Ulam prime numbers less or equal to m in a vector up. Also compute their frequency / ratio f compare to all the primes in the same range. If m is not a positive integer greater or equal to 1847, your function should return up = [] and f = 0.\r\n\r\nExamples\r\n\r\nIf m = 1847 then up = 1847 and f = 1 since 1847 = P(0) and it is the only prime number m greater or equal and less or equal to 1847;\r\nIf m = 3000 then up = [1847, 2203, 2393, 2591, 2797] and f = 5/148 since 1847 = P(0), 2203 = P(2), 2393 = P(3), 2591 = P(4), 2797 = P(5), and there are in total 30 prime numbers in the range [1847; 3000] ; \r\nIf m = 1823 then up = [] and f = 0;\r\n\r\n\r\nTip \r\n\r\nn is less or equal to 2000 here.\r\n\r\n\r\nFobidden functions\r\n\r\nregexp\r\nassignin\r\nstr2num\r\n\r\n\r\nSee also\r\nUlam primes second formula\r\nEuler primes\r\nPrime numbers properties II","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 1069.47px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 534.733px; transform-origin: 408px 534.733px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 58.725px 8px; transform-origin: 58.725px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eHistorical context\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 21px; text-align: left; transform-origin: 385px 21px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 219.4px 8px; transform-origin: 219.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe polish-american mathematician Stanislaw Ulam found the formula \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVQAAAAnCAYAAABQU7BuAAALq0lEQVR4Xu1dWehuUxR3I8qQ6cGQKDyYMs9ThlCG5MHwIN2QKUMeCA+6SWR6MGTKwyUZQ8qcKJIxIeIBRRlSpgwRYv04S+uuu/bZe5+99/ed8/+vU6v/vd+3zx5+e+3fXmvt4Vuyij+OgCPgCDgCVRBYUiUXz8QRcAQcAUdgFSdUVwJHwBFwBCoh4IRaCUjPxhFwBBwBJ1TXAUfAEXAEKiHghFoJyAWczVbUtqtITuja+BX9vZDkwQXcZm+aIzAIgXkS6hVU4+1IriF5c1Dt7ZcOp49PJnnSB30xqhtQDp+RrG3kdDZ9dntxCZ6BI7CAEJgXoT5GGO5P8g7JYZXxBAm8SLJF9/e4yvkvpuxghe5IciPJliQgUSZXWKqbLiYwvK2OQAwBTahn0QuXk2wSe5G+/5nkA5J3SR4heS7hHSQBmR7avbtP4ju5yUCqqNt6JM+QLGRS/ZDatw3J6yR75wLVkx6u/hMkR5N80qWDftwm3tmQ/v1dxTJbZ4U2nUmCiWGdQGHwcJ7NrMjWAiN+FWVdTHIgyY8km5O8THKZkTazuMknP5FagLDRSx1GfQ1iHHfqEq3b/f2c/oJLhnhJfWPmNcpzrwyEH6K0aM+/T8hCvZS+Q9xMP3vSB3DP0chbSaB8/GBAn9d9H6rPtfTFuSSrkWxM0nIwglQB+p8kl5AMAT4D17kkvYNKPaMruQWhAkMdjvm7Kw8W6g6N+7AWqNDT00g4Dox8c3U/VJeP6Itt1ZcoD0YGrPkjSGBs8JiCIXI6yWKLQUOXMJmBI9hgu47+jUkn9Ej9liEmObED//0y9DA2Zn7q+i1V906SfRlSKjT+W5WjNWA1m0NZ4GpbRMkzPwbkOSSzIDjEaWER/EGCwc+WVipYY06nLanahGq1XeoFSAJkMeYHA+8CEljw+gnpPohOEm+sfdCvq0UiGBsIZYFMdVjkS/oMZIJxsvMC08cQTryoeWSHiUzXR6gwvi7qElu6JrknVfdjYwZ1/TjW4eJ79OMKnk5fDJUtEX7fqrRlya5gAovCYensSoIZAK74rJ4fuka/TX/3mFWhjcuxFotSlaqkanBtHugI4RD6W3MxsaRe1rtw6+BSvkBylzGYQ7rP7mBqfbS7Lwe6JoIhJJBajzGmAz8cRALX/GASPVGFCFUbdFY6zT3sPYdwSBkzrN+pWK7EdaWEasWbrMWKeVinDMpN9A+4GXhioKcCOe90GJiIJUnLaxaEyoSgrbISPKQlwu5xSX7Wu7IM/j6k+zAkQIQ39FQCi3TAXrv7mLDfEO9pItD1GJM+sgHVUo+0kRYiVM0robCKjHXHdCdlzKB/EFqAZfxpoP93o885HLqCu4/0LQjVyhcNx2o+ypv1Qgab8ejMh0n+DyDXHrUzyo9nfSwGskuEolsOBOTPFkFNMkW+YyJUDOTlJH27F6T1pLGQ8Tm0LUaod1IaxBXH8IyZUIGP3qanLdQ+XkkdMyBd9H9fOJL7eCV3vxWh6oKkAn5BhW42B+2B2w+L7leSteZQfq0iYQE9ToJ4MBbaZkWoKBeuM2ZmGS/E56Vu/5gIlSfbvgUjuSCi3X0dLogRqmV51dKV3HzGRKja0ue2SFKV4ZO+WGzOmEG/xwwujoOboc0WFqqOG8m4xN1U4aWBnuaG6y1bbMpj4B1DAlcLpP1UN2ul7BR4ldLylqIxuVk5So+J6RUSLLIAY+0+agtVW0soi9MA6ytJ9iXB4gkG9jISi0hQ7vskNysyRb+eSlK6MDUmQk3pDyZNiwxjLm0o9NBS91PahDRjIlTUJ7R9CUT2KAnH8vUkL9ubO2ZiWEkuW8ndx8ulhGqtiOpYhlSi2DYJK3CMimOwWyu1qTO8rMNUT/iAIPGwixgjVKS10iynz+VeUqlEWklYIeFVYF+vfLBXL9afMQXVdYzFwVLys9LkxFD7ypCrwNrdt6yqmIWKsniCb6X7qZiNjVDZK7JO6aFNIFaM5T6DasiY6cOL+c509/FiCaHqTd7IzyIrxE95v2rKgNEzE6wqkAAAXJ8Em6OlFZtCkDmknjogUxVVpxtyOg0z4zISud8uhVB1cB8LhsDvehK46joPvaAo+85qrzlLZwIzJQtVxu20u28t0KYQqhwTLXQ/tTvGRqiod4xU+yb0oWOmDy/eoxrayZRFqBhs95Jgn+kBitRgKbIrqisklWQIoWrQtCubsh9SKnsQjB4kLQsnVVFLCZUtF71NaQihoi6S0K39xmwxWSED3ZYaC4xTIlSOn6WsOgOrUkKtofupejpGQkXdoaP3k8hDRLJN1nguGTMhvKQBGTQkcixUJlRZ4Pf0n+c7aydUkdqEmkIkui6SUIeshgPMpamaGUmXezwU+FlH9FJwsKwm3ec67pcy6VWC4t9spkKo0qW3djq0sFBjhDxEl0N9N0ZC5Vg/sIXhxDF/3Qa9W6JkzITwYW8t6O5ra0VnlLKxP2VgLQRCTWlnizRwMU8h0UcbNRHh/9bgGgOh1rTuh5J9jRiqtNits/tjJ1Q9nofqawmJxxbtZJ2kRcihKBDsPSTWegr3SemYsXCRnlyvh5tjoQ4FcgyEKlfnxrT3L6bUUEAoE+4k0A8u25CxZHlZDS9cOaH+h1oNQuX4Wd9CaIwwYvXQMdSaFuqUCFUe30X/yXUSXijVpMpYlY4Za0zK2HnvusEsCFXuBEixMFooVemiVIz4Wn0/ZBDIiW8MhBoLl8iJAWSFm5lCT+zyndB7MSKL9Z+ckPsONpTuQ22h+9w25N338A1LPDGH0uJAydDDCLEJh8vUm/a1R2DtiGDLsXTMWO3mfu119/HiLAg1l8xaKJWsw5CV6Zpua84qf6lyjIFQY2Q1hRiqNAosd5/bWHpSqoXux/Dn78cUQ9XbMa0xo9Ow51k6ZjRecqtcdEF7FoQqBzVu0cf9mn1PC6WSlkPfgMixcFIVVafLIdQ+q2IqLn8Mp7ETqrSGYvueS8/yt9D9GP5jJFQ9MVljRhs57DmUjhmNV5YxNgtCRQV/IVmTJOXoaQul+p3KXp3kG5KNUjVMpIu5rTlZ5q7yp5L8WBelYtiMnVDl4kjKPQZy767e0ie/s/qrhe7H8B8joeo97pYRpEk3xVBK2Rmj8ZJXLoYuJf//nRChWvcCRuMHPT0H8/x4EpQXa3htpZIWco2TPakK2jpdinK4y/9fL1ghm9Q9tJIEU97puw9VxuKs+1Br636ODs7D5Q8tEPNxZ150tcYtEx3amLrQnDJmJGbS40gqI0SooU3dQ8/By4GNM+HnB3raCjbrhujYScwNw894HNWVFyPzHAWcd9oU5YgRiTVxDokxl2DR2kLVg5PrmmJtDr1QW57wYTx5DMAwse6SbaH7Of3SmlD1QhPq1verD/J+A/krB8AJR6f5btUkouuASBkzEjPJg0ncN+Q3pQACbsLPvXE/dsF06IIIOQNZdwfge5Aq9mvqm48A/tckUJblJENXJ3MUc1ZpY8oRmhTRf8d2lcQNUvqsNJT3vhli1YpQOZbW9/tAvKsgtHtAkkDKEWfZ99A93AiGC32wcwG3neGABvLU589b6H6uHrYgVA6V6Xi/rJu13Y+/B4YgzqUk2wtdRb+9R8JHqFPbGhszOh/eKmfd8WyWmbNAklrpUDpYQ7i1aA2SW0hCVmppOfJ9HFnDlpffSHDBR8rNVDXL97ziCLQi1HjJnkIi0IJQFx3CsyRUgIsZC7PKqiT4NcjSuzT7Ogwu1tMkf5FgZwEWCPwZHwJywW/oPtPxtWp6NWKLvmSf6fRaXbnGsyZUVB8WCVxvXPYMM76F1QhXYaH/4mllVfDsHAFHoBSBeRAqW6rLOlLdvTKpgkzfIsE2LZSRG+stxdTfdwQcgUWKwLwIFXDDJd+FBAsjNV3/VvkuUhXxZjsCjkAqAvMk1NQ6ejpHwBFwBCaBgBPqJLrJK+kIOAJTQMAJdQq95HV0BByBSSDghDqJbvJKOgKOwBQQcEKdQi95HR0BR2ASCPwDPACqVQlvtokAAAAASUVORK5CYII=\" width=\"170\" height=\"19.5\" style=\"width: 170px; height: 19.5px;\"\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63px 8px; transform-origin: 63px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e to give the first 760 prime numbers not given by Euler's formula. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63.0083px 8px; transform-origin: 63.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eProblem statement\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 31.5px; text-align: left; transform-origin: 385px 31.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 60.2917px 8px; transform-origin: 60.2917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor a given integer \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 6.225px 8px; transform-origin: 6.225px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 33.8583px 8px; transform-origin: 33.8583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em \u0026gt;= 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 138.475px 8px; transform-origin: 138.475px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003elist the Ulam prime numbers less or equal to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 5.83333px 8px; transform-origin: 5.83333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003em\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40.0583px 8px; transform-origin: 40.0583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e in a vector u\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ep\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 63.7833px 8px; transform-origin: 63.7833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Also compute their frequency / ratio \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ef \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 286.658px 8px; transform-origin: 286.658px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ecompare to all the primes in the same range. If m is not a positive integer greater or equal to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5667px 8px; transform-origin: 15.5667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eyour function should return\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.075px 8px; transform-origin: 25.075px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e up = [] \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 11.675px 8px; transform-origin: 11.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 18.0833px 8px; transform-origin: 18.0833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e f = 0.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 32.675px 8px; transform-origin: 32.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExamples\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 102.167px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 51.0833px; transform-origin: 392px 51.0833px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 5.825px 8px; transform-origin: 5.825px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 29.7667px 8px; transform-origin: 29.7667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em = 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethen\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 6.21667px 8px; transform-origin: 6.21667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e u\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 27.8167px 8px; transform-origin: 27.8167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ep = 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.675px 8px; transform-origin: 11.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 16.1417px 8px; transform-origin: 16.1417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ef = 1 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 33.85px 8px; transform-origin: 33.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.2px 8px; transform-origin: 21.2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e = P(0)\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 99.575px 8px; transform-origin: 99.575px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and it is the only prime number \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 5.83333px 8px; transform-origin: 5.83333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003em\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 81.3px 8px; transform-origin: 81.3px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e greater or equal and less or equal to 1847\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2.33333px 8px; transform-origin: 2.33333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 20.4333px; text-align: left; transform-origin: 364px 20.4333px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 5.825px 8px; transform-origin: 5.825px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 29.7667px 8px; transform-origin: 29.7667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em = 3000\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 13.6167px 8px; transform-origin: 13.6167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethen\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 6.21667px 8px; transform-origin: 6.21667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e u\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 110.283px 8px; transform-origin: 110.283px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ep = [1847, 2203, 2393, 2591, 2797]\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 11.675px 8px; transform-origin: 11.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 29.7583px 8px; transform-origin: 29.7583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ef = 5/148 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 18.2833px 8px; transform-origin: 18.2833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 121.95px 8px; transform-origin: 121.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e1847 = P(0), 2203 = P(2), 2393 = P(3), 2591 = P(4), 2797 = P(5), \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 73.9083px 8px; transform-origin: 73.9083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eand there are in total 30\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 85.5833px 8px; transform-origin: 85.5833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eprime numbers in the range\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 46.6667px 8px; transform-origin: 46.6667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e [1847; 3000] ; \u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 31.7083px 8px; transform-origin: 31.7083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003em = 1823 \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 19.45px 8px; transform-origin: 19.45px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethen u\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 16.9167px 8px; transform-origin: 16.9167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ep = []\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 14.2px 8px; transform-origin: 14.2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; font-weight: 700; \"\u003ef = 0\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 10.3667px 8px; transform-origin: 10.3667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eTip\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.89167px 8px; transform-origin: 3.89167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 91.8px 8px; transform-origin: 91.8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is less or equal to 2000 here.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 64.9167px 8px; transform-origin: 64.9167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eFobidden functions\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 392px 30.65px; transform-origin: 392px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.4px 8px; transform-origin: 21.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eregexp\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.6833px 8px; transform-origin: 25.6833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eassignin\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 364px 10.2167px; text-align: left; transform-origin: 364px 10.2167px; white-space-collapse: preserve; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 25.2833px 8px; transform-origin: 25.2833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003estr2num\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.3917px 8px; transform-origin: 28.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eSee also\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/groups/95630/problems/60943-ulam-primes-second-formula/\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eUlam primes second formula\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/problems/60942-euler-primes\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eEuler primes\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://fr.mathworks.com/matlabcentral/cody/groups/95759\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ePrime numbers properties II\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [up,f] = ulam_primes1(m)\r\n  up = m;\r\n  f = 1;\r\nend","test_suite":"%%\r\nm = 1847;\r\nup_correct = 1847;\r\nf_correct = 1;\r\n[up,f] = ulam_primes1(m);\r\nassert(isequal([up,f],[up_correct,f_correct]));\r\n\r\n%%\r\nm = 3000;\r\nup_correct = [1847, 2203, 2393, 2591, 2797];\r\nf_correct = 5/148;\r\n[up,f] = ulam_primes1(m);\r\nassert(isequal([up,f],[up_correct,f_correct]));\r\n\r\n%%\r\nm = 1823;\r\nup_correct = [];\r\nf_correct = 0;\r\n[up,f] = ulam_primes1(m);\r\nassert(isequal([up,f],[up_correct,f_correct]));\r\n\r\n%% Forbidden functions\r\nfiletext = fileread('ulam_primes1.m');\r\nillegal = contains(filetext, 'regexp') || contains(filetext, 'str2num') || contains(filetext, 'assignin') || contains(filetext, 'echo')\r\nassert(~illegal);","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":149128,"edited_by":149128,"edited_at":"2025-07-26T07:08:08.000Z","deleted_by":null,"deleted_at":null,"solvers_count":20,"test_suite_updated_at":"2025-07-09T05:56:57.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2025-06-26T19:59:43.000Z","updated_at":"2026-03-17T10:54:41.000Z","published_at":"2025-06-26T20:23:34.000Z","restored_at":null,"restored_by":null,"spam":null,"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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHistorical context\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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\u003eThe polish-american mathematician Stanislaw Ulam found the formula \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\mathbf{P(n) = 4n^2 + 170n + 1847}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e to give the first 760 prime numbers not given by Euler's formula. \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\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eProblem statement\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\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\u003eFor a given integer \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em \u0026gt;= 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003elist the Ulam prime numbers less or equal to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in a vector u\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Also compute their frequency / ratio \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ecompare to all the primes in the same range. If m is not a positive integer greater or equal to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eyour function should return\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e up = [] \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e f = 0.\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em = 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e u\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep = 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef = 1 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003esince 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e = P(0)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and it is the only prime number \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e greater or equal and less or equal to 1847\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em = 3000\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e u\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep = [1847, 2203, 2393, 2591, 2797]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef = 5/148 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003esince \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1847 = P(0), 2203 = P(2), 2393 = P(3), 2591 = P(4), 2797 = P(5), \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand there are in total 30\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eprime numbers in the range\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e [1847; 3000] ; \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003em = 1823 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003ethen u\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep = []\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ef = 0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTip\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is less or equal to 2000 here.\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\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFobidden functions\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexp\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassignin\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estr2num\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\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\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSee also\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/groups/95630/problems/60943-ulam-primes-second-formula/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUlam primes second formula\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/problems/60942-euler-primes\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eEuler primes\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:hyperlink w:docLocation=\\\"https://fr.mathworks.com/matlabcentral/cody/groups/95759\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePrime numbers properties II\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":42510,"title":"Divisible by n, Composite Divisors","description":"Pursuant to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\r\n\r\nAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\r\n\r\nThe only restriction that remains is Java.\r\n\r\n* Divisible by 2: if the last digit is divisible by 2.\r\n* Divisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\r\n* Divisible by 4: if the last two digits are divisible by 4.\r\n* Divisible by 5: if the last digit is a 0 or 5.\r\n* Divisible by 8: if the last three digits are divisible by 8.\r\n* Divisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\r\n* Divisible by 10: if the last digit is zero.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors Divisible by n, Truncated-number Divisors\u003e.","description_html":"\u003cp\u003ePursuant to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\u003c/p\u003e\u003cp\u003eAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\u003c/p\u003e\u003cp\u003eThe only restriction that remains is Java.\u003c/p\u003e\u003cul\u003e\u003cli\u003eDivisible by 2: if the last digit is divisible by 2.\u003c/li\u003e\u003cli\u003eDivisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/li\u003e\u003cli\u003eDivisible by 4: if the last two digits are divisible by 4.\u003c/li\u003e\u003cli\u003eDivisible by 5: if the last digit is a 0 or 5.\u003c/li\u003e\u003cli\u003eDivisible by 8: if the last three digits are divisible by 8.\u003c/li\u003e\u003cli\u003eDivisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/li\u003e\u003cli\u003eDivisible by 10: if the last digit is zero.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\"\u003eDivisible by n, Truncated-number Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = composite_divisors(n,n_str)\r\n\r\ntf = 1;\r\n\r\nend\r\n","test_suite":"%%\r\nfiletext = fileread('composite_divisors.m');\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 18;\r\nn_str = '612220032';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '612220031';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '64268410079232';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '64268410079230';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 30;\r\nn_str = '64268410079230';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 30;\r\nn_str = '64268410079220';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 90;\r\nn_str = '47829690000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 90;\r\nn_str = '47829690000001';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '101559956668416';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '101559956668417';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '3046798700052480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '3046798700052480000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '262144000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '262144000000008';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '52428800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '52428800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '4586471424';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '45864714247';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '26418075402240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '26418075402240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":76,"test_suite_updated_at":"2015-08-18T17:06:20.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-18T01:06:51.000Z","updated_at":"2026-01-11T11:13:47.000Z","published_at":"2015-08-18T01:06:51.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\u003ePursuant to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\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\u003eAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\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 only restriction that remains is Java.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 2: if the last digit is divisible by 2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 4: if the last two digits are divisible by 4.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 5: if the last digit is a 0 or 5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 8: if the last three digits are divisible by 8.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 10: if the last digit is zero.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Truncated-number Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"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":42914,"title":"Counting the Grand Primes","description":"A grand prime pair is a pair of primes, p1 and p2=p1+1000, such that both numbers are prime. Like a twin prime pair, where the difference is 2, the members of a grand prime pair always have a difference of 1000. Some facts about grand prime pairs, so that you can test your code:\r\n\r\n1. The smallest grand prime pair is [13,1013], the 100th such pair is [3229,4229].\r\n\r\n2. There are 37 grand prime pairs such that the larger element of the pair is no larger than 2000.\r\n\r\n3. There should be infinitely many grand prime pairs.\r\n\r\n4. All such grand prime pairs must have the property that the smaller element of the pair is of the form 6*k+1, for some integer k.\r\n\r\nWrite a function that counts the number of grand prime pairs that exist, such that the larger element of the pair is no larger than N. I'll be nice and not ask you to compute that result for N too large, 1e8 seems a reasonable upper limit.","description_html":"\u003cp\u003eA grand prime pair is a pair of primes, p1 and p2=p1+1000, such that both numbers are prime. Like a twin prime pair, where the difference is 2, the members of a grand prime pair always have a difference of 1000. Some facts about grand prime pairs, so that you can test your code:\u003c/p\u003e\u003cp\u003e1. The smallest grand prime pair is [13,1013], the 100th such pair is [3229,4229].\u003c/p\u003e\u003cp\u003e2. There are 37 grand prime pairs such that the larger element of the pair is no larger than 2000.\u003c/p\u003e\u003cp\u003e3. There should be infinitely many grand prime pairs.\u003c/p\u003e\u003cp\u003e4. All such grand prime pairs must have the property that the smaller element of the pair is of the form 6*k+1, for some integer k.\u003c/p\u003e\u003cp\u003eWrite a function that counts the number of grand prime pairs that exist, such that the larger element of the pair is no larger than N. I'll be nice and not ask you to compute that result for N too large, 1e8 seems a reasonable upper limit.\u003c/p\u003e","function_template":"function y = grandPrimeCounter(N)\r\n  y = N;\r\nend","test_suite":"%%\r\nN = 1000;\r\ny_correct = 0;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 1234;\r\ny_correct = 13;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 12345;\r\ny_correct = 280;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 123456;\r\ny_correct = 1925;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 1234567;\r\ny_correct = 13142;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n\r\n%%\r\nN = 99999900;\r\ny_correct = 586509;\r\nassert(isequal(grandPrimeCounter(N),y_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":544,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-07-22T17:41:15.000Z","updated_at":"2026-03-16T15:24:57.000Z","published_at":"2016-07-22T18:20:37.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eA grand prime pair is a pair of primes, p1 and p2=p1+1000, such that both numbers are prime. Like a twin prime pair, where the difference is 2, the members of a grand prime pair always have a difference of 1000. Some facts about grand prime pairs, so that you can test your code:\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\u003e1. The smallest grand prime pair is [13,1013], the 100th such pair is [3229,4229].\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\u003e2. There are 37 grand prime pairs such that the larger element of the pair is no larger than 2000.\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\u003e3. There should be infinitely many grand prime pairs.\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\u003e4. All such grand prime pairs must have the property that the smaller element of the pair is of the form 6*k+1, for some integer k.\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\u003eWrite a function that counts the number of grand prime pairs that exist, such that the larger element of the pair is no larger than N. I'll be nice and not ask you to compute that result for N too large, 1e8 seems a reasonable upper limit.\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\"}]}"},{"id":3003,"title":"Mobius function","description":"From wikipedia:\r\nFor any positive integer n, define μ(n) as the sum of the primitive n-th roots of unity. It has values in {−1, 0, 1} depending on the factorization of n into prime factors:\r\nμ(n) = 1 if n is a square-free positive integer with an even number of prime factors.\r\nμ(n) = −1 if n is a square-free positive integer with an odd number of prime factors.\r\nμ(n) = 0 if n has a squared prime factor.\r\nReturn numbers from the Mobius function sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [-1, 0, -1, 1, -1].\r\nHint: solving Problem 3001 and Problem 3002 will provide much of the code needed for this problem. You'll need to add prime numbers to the sphenic number set (resulting from Problem 3001).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; 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: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 256.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 128.15px; transform-origin: 407px 128.15px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 16.5px 8px; transform-origin: 16.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFrom\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ewikipedia\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 380px 8px; transform-origin: 380px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor any positive integer n, define μ(n) as the sum of the primitive n-th roots of unity. It has values in {−1, 0, 1} depending on the factorization of n into prime factors:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 30.65px; transform-origin: 391px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 259px 8px; transform-origin: 259px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eμ(n) = 1 if n is a square-free positive integer with an even number of prime factors.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 259.5px 8px; transform-origin: 259.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eμ(n) = −1 if n is a square-free positive integer with an odd number of prime factors.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 125px 8px; transform-origin: 125px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eμ(n) = 0 if n has a squared prime factor.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 79px 8px; transform-origin: 79px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn numbers from the\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eMobius function sequence\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 214.5px 8px; transform-origin: 214.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e corresponding to the supplied indices. For example, if n = 3:7, your function should return [-1, 0, -1, 1, -1].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 38px 8px; transform-origin: 38px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHint: solving\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3001-sphenic-number-sequence\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3001\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14px 8px; transform-origin: 14px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3002-not-square-free-number-sequence\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3002\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 232.5px 8px; transform-origin: 232.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e will provide much of the code needed for this problem. You'll need to add prime numbers to the sphenic number set (resulting from Problem 3001).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [arr] = mobius_func_seq(n)\r\n\r\narr =n;\r\n\r\nend\r\n","test_suite":"%%\r\nn = 1:5;\r\narr_corr = [1, -1, -1, 0, -1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 1:10;\r\narr_corr = [1, -1, -1, 0, -1, 1, -1, 0, 0, 1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 3:7;\r\narr_corr = [-1, 0, -1, 1, -1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 20:30;\r\narr_corr = [0     1     1    -1     0     0     1     0     0    -1    -1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 99;\r\narr_corr = 0;\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%%\r\nn = 1:77;\r\narr_corr = [1, -1, -1, 0, -1, 1, -1, 0, 0, 1, -1, 0, -1, 1, 1, 0, -1, 0, -1, 0, 1, 1, -1, 0, 0, 1, 0, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, 1, 1, 0, -1, -1, -1, 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 1, 0, 1, 1, -1, 0, -1, 1, 0, 0, 1, -1, -1, 0, 1, -1, -1, 0, -1, 1, 0, 0, 1];\r\nassert(isequal(mobius_func_seq(n),arr_corr))\r\n\r\n%% prevents cheating\r\ni1 = randi(20,1);\r\nn = i1:(i1+randi(25,1));\r\narr_tot = [1, -1, -1, 0, -1, 1, -1, 0, 0, 1, -1, 0, -1, 1, 1, 0, -1, 0, -1, 0, 1, 1, -1, 0, 0, 1, 0, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, 1, 1, 0, -1, -1, -1, 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 1, 0, 1, 1, -1, 0, -1, 1, 0, 0, 1, -1, -1, 0, 1, -1, -1, 0, -1, 1, 0, 0, 1];\r\narr_corr = arr_tot(n);\r\nassert(isequal(mobius_func_seq(n),arr_corr))","published":true,"deleted":false,"likes_count":5,"comments_count":3,"created_by":26769,"edited_by":223089,"edited_at":"2022-10-09T11:44:37.000Z","deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":"2022-10-09T11:44:37.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-02-11T03:05:35.000Z","updated_at":"2026-03-16T14:39:18.000Z","published_at":"2015-02-11T03:05:35.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\u003eFrom\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ewikipedia\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\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\u003eFor any positive integer n, define μ(n) as the sum of the primitive n-th roots of unity. It has values in {−1, 0, 1} depending on the factorization of n into prime factors:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eμ(n) = 1 if n is a square-free positive integer with an even number of prime factors.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eμ(n) = −1 if n is a square-free positive integer with an odd number of prime factors.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eμ(n) = 0 if n has a squared prime factor.\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\u003eReturn numbers from the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMobius function sequence\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e corresponding to the supplied indices. For example, if n = 3:7, your function should return [-1, 0, -1, 1, -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\u003eHint: solving\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3001-sphenic-number-sequence\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3001\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3002-not-square-free-number-sequence\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3002\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e will provide much of the code needed for this problem. You'll need to add prime numbers to the sphenic number set (resulting from Problem 3001).\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":42453,"title":"Divisible by n, prime vs. composite divisors","description":"In general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\r\n\r\n  n = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\n  n = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\n  n = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\n  n = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\n  n = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\n  n = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\n  n = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\n  n = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\n  n = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\n  n = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16 divisible by 16\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e.","description_html":"\u003cp\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\u003c/pre\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\"\u003edivisible by 16\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_type,hpf] = composite_vs_prime_divisor(n)\r\n\r\nn_type = 1;\r\nhpf = [1];\r\n\r\nend\r\n","test_suite":"%%\r\nn = 5;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 5;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 7;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 7;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 15;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,5];\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 25;\r\ntf_corr = 2; %composite factor, prime power (5^2)\r\nhpf_corr = 25;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 125;\r\ntf_corr = 2; %composite factor, prime power (5^3)\r\nhpf_corr = 125;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 20;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [4,5];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 42;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,3,7];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 18;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,9];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 29;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 29;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 39;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,13];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 64;\r\ntf_corr = 2; %composite factor, prime power (2^6)\r\nhpf_corr = 64;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 27;\r\ntf_corr = 2; %composite factor, prime power (3^3)\r\nhpf_corr = 27;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 29;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 29;\r\n\tcase 2\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 64;\r\n\t\ttf_corr = 2; %composite factor, prime power (2^6)\r\n\t\thpf_corr = 64;\r\n\tcase 2\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\n\tcase 3\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 4\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 39;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [3,13];\r\n\tcase 2\r\n\t\tn = 5;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 5;\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":113,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:29:13.000Z","updated_at":"2026-01-11T11:07:59.000Z","published_at":"2015-07-09T01:29:13.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\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\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[n = 11  |  n_type = 1 (prime)        |  hpf = [11]\\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\\\"\u003e\u003cw:r\u003e\u003cw:t\u003edivisible by 16\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":525,"title":"Mersenne Primes","description":"A Mersenne prime is a prime number of the form M = 2^p - 1, where p is another prime number.  For example, 31 is a Mersenne prime because 31 = 2^5 - 1 and both 31 and 5 are prime numbers.\r\n\r\nImplement the function isMersenne(x) so that it returns true if x is a Mersenne prime and false otherwise.  Your solution should work for all positive integer values of x less than 1,000,000,000 (one billion).","description_html":"\u003cp\u003eA Mersenne prime is a prime number of the form M = 2^p - 1, where p is another prime number.  For example, 31 is a Mersenne prime because 31 = 2^5 - 1 and both 31 and 5 are prime numbers.\u003c/p\u003e\u003cp\u003eImplement the function isMersenne(x) so that it returns true if x is a Mersenne prime and false otherwise.  Your solution should work for all positive integer values of x less than 1,000,000,000 (one billion).\u003c/p\u003e","function_template":"function y = isMersenne(x)\r\n  y = false;\r\nend","test_suite":"%%\r\nx = 3;\r\ny_correct = true;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 127;\r\ny_correct = true;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 157;\r\ny_correct = false;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 2047;\r\ny_correct = false;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 8191;\r\ny_correct = true;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 524287;\r\ny_correct = true;\r\nassert(isequal(isMersenne(x),y_correct))\r\n\r\n%%\r\nx = 536870911;\r\ny_correct = false;\r\nassert(isequal(isMersenne(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":4,"created_by":1537,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":968,"test_suite_updated_at":"2012-03-24T15:03:26.000Z","rescore_all_solutions":false,"group_id":44,"created_at":"2012-03-24T14:32:54.000Z","updated_at":"2026-04-09T08:32:03.000Z","published_at":"2012-03-24T14:36:27.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eA Mersenne prime is a prime number of the form M = 2^p - 1, where p is another prime number. For example, 31 is a Mersenne prime because 31 = 2^5 - 1 and both 31 and 5 are prime numbers.\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\u003eImplement the function isMersenne(x) so that it returns true if x is a Mersenne prime and false otherwise. Your solution should work for all positive integer values of x less than 1,000,000,000 (one billion).\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\"}]}"},{"id":1722,"title":"Find the next prime number","description":"Find the next prime number or numbers for given n. For example:\r\n\r\n  n = 1;\r\n  out = 2;\r\n\r\nor\r\n\r\n  n = [5 7];\r\n  out = [7 11];\r\n\r\nGood luck!\r\n","description_html":"\u003cp\u003eFind the next prime number or numbers for given n. For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1;\r\nout = 2;\r\n\u003c/pre\u003e\u003cp\u003eor\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = [5 7];\r\nout = [7 11];\r\n\u003c/pre\u003e\u003cp\u003eGood luck!\u003c/p\u003e","function_template":"function y = nextprimenum(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nn = 1;\r\nout = 2;\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = 7;\r\nout = 11;\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = [1 2 3 4 5 6 7 8 9];\r\nout = [2 3 5 5 7 7 11 11 11];\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = [71 25 63 47 65 36 47 58 69];\r\nout = [73 29 67 53 67 37 53 59 71];\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = [171 255 636 487 675 369 477 538 969];\r\nout =  [173 257 641 491 677 373 479 541 971];\r\nassert(isequal(nextprimenum(n),out))\r\n%%\r\nn = [172541 255564 632436 4564587 6778675 334469 475647 575638 96879];\r\nout =  [172553 255571 632447 4564589 6778691 334487 475649 575647 96893];\r\nassert(isequal(nextprimenum(n),out))","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":15013,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":837,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-17T21:54:33.000Z","updated_at":"2026-04-09T08:29:05.000Z","published_at":"2013-07-17T21:54:32.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\u003eFind the next prime number or numbers for given n. For example:\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[n = 1;\\nout = 2;]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eor\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[n = [5 7];\\nout = [7 11];]]\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood luck!\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\"}]}"},{"id":42508,"title":"Divisible by n, prime divisors from 20 to 200","description":"Pursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\r\n\r\n* 2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u003e 2048379 is not divisible by 127 since 54 is not divisible by 127.\r\n\r\n* 4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u003e 4853940 is divisible by 127.\r\n\r\nYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\r\n\r\nRestrictions on Java, mod, ceil, round, and floor are still in effect.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors Divisible by n, Truncated-number Divisors\u003e.","description_html":"\u003cp\u003ePursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\u003c/p\u003e\u003cul\u003e\u003cli\u003e2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u0026gt; 2048379 is not divisible by 127 since 54 is not divisible by 127.\u003c/li\u003e\u003c/ul\u003e\u003cul\u003e\u003cli\u003e4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u0026gt; 4853940 is divisible by 127.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\u003c/p\u003e\u003cp\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\"\u003eDivisible by n, Truncated-number Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = prime_divisors_20_to_200(n,n_str)\r\n\r\np_digits =      [23 29  31 37  41 43  47 53 59 61 67  71 73 79 83 89 97  101 103 107 109 113 127 131 137 139  149  151 157 163  167 173  179  181 191 193  197 199];\r\nlast_dig_mult = [7  3  -3 -11 -4  13 -14 16 6 -6 -20 -7 -51 8  25 9 -29 -10 -72 -32 -98 -79 -38 -13 -41 -125 -134 -15 -47 -114 -50 -121 -161 -18 -19 -135 -59 -179];\r\n\r\ntf = 1;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('prime_divisors_20_to_200.m');\r\nassert(isempty(strfind(filetext, 'rem')),'rem() forbidden')\r\nassert(isempty(strfind(filetext, 'mod')),'mod() forbidden')\r\nassert(isempty(strfind(filetext, 'round')),'round() forbidden')\r\nassert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden')\r\nassert(isempty(strfind(filetext, 'floor')),'floor() forbidden')\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 23;\r\nn_str = '943';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 23;\r\nn_str = '9430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 23;\r\nn_str = '9430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 29;\r\nn_str = '22649';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '992';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '9920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '9920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 37;\r\nn_str = '4107';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 41;\r\nn_str = '33292';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '85140';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '851400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '851400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 47;\r\nn_str = '232603';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 53;\r\nn_str = '148877';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 59;\r\nn_str = '12698688';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '61965813';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '619658130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '619658130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 67;\r\nn_str = '22319844';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 71;\r\nn_str = '25411681';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 73;\r\nn_str = '328500';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 73;\r\nn_str = '32850000000000000000000000000000000000000000000000000000000000001000000000000';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 79;\r\nn_str = '41977440';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 83;\r\nn_str = '342873';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 89;\r\nn_str = '8900000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 97;\r\nn_str = '88529281';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '104060401';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '1040604010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '1040604010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 103;\r\nn_str = '112550881';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 107;\r\nn_str = '515205';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 109;\r\nn_str = '141158161';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294000000000000000000000000113000000000000000000000000113000000000000000000000000113000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294000000000000000000000000113000000000000000000000000113000000000000000000000000113000000000000000000000112';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 127;\r\nn_str = '4853940';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 131;\r\nn_str = '294499921';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 137;\r\nn_str = '249421241';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '2685619';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '268561900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '268561900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000000000000000013';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 149;\r\nn_str = '512977200';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 151;\r\nn_str = '141160991';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 157;\r\nn_str = '607573201';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 163;\r\nn_str = '705911761';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 167;\r\nn_str = '777796321';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 173;\r\nn_str = '154963892093';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 179;\r\nn_str = '98682340334763';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 181;\r\nn_str = '35161828327081';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 191;\r\nn_str = '884089868985578';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 193;\r\nn_str = '1387488001';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 197;\r\nn_str = '27000544548887';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '328039798800';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000199000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000001991000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000199000000000000';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-17T19:05:44.000Z","updated_at":"2025-12-27T11:58:28.000Z","published_at":"2015-08-17T19:05:44.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\u003ePursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u0026gt; 2048379 is not divisible by 127 since 54 is not divisible by 127.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u0026gt; 4853940 is divisible by 127.\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\u003eYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\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\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Truncated-number Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":42455,"title":"Divisible by n, prime divisors - 11, 13, 17, \u0026 19","description":"Divisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\r\n\r\n* 2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u003e 2392 is divisible by 13.\r\n\r\nFor 17, subtract five times the last digit from the rest:\r\n\r\n* 3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u003e 3281 is divisible by 17.\r\n\r\nFor 19, add two times the last digit to the rest:\r\n\r\n* 16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u003e 16863 is not divisible by 19.\r\n\r\nAnd, for 11, subtract the last digit from the rest:\r\n\r\n* 269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u003e 269830 is divisible by 11.\r\n\r\nWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\r\n\r\nRestrictions on Java, mod, ceil, round, and floor are still in effect.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200 Divisible by n, prime divisors from 20 to 200\u003e.","description_html":"\u003cp\u003eDivisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u0026gt; 2392 is divisible by 13.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 17, subtract five times the last digit from the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u0026gt; 3281 is divisible by 17.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 19, add two times the last digit to the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u0026gt; 16863 is not divisible by 19.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eAnd, for 11, subtract the last digit from the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u0026gt; 269830 is divisible by 11.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\u003c/p\u003e\u003cp\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\"\u003eDivisible by n, prime divisors from 20 to 200\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = prime_divisors_11_to_20(n)\r\n\r\np_digits = [11 13 17 19];\r\ntf = zeros(1,4); %[11 13 17 19]\r\n\t\r\nend\r\n","test_suite":"%%\r\nfiletext = fileread('prime_divisors_11_to_20.m');\r\nassert(isempty(strfind(filetext, 'mod')),'mod() forbidden')\r\nassert(isempty(strfind(filetext, 'round')),'round() forbidden')\r\nassert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden')\r\nassert(isempty(strfind(filetext, 'floor')),'floor() forbidden')\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = '143';\r\ntf = [1 1 0 0]; %[11 13 17 19]\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '187';\r\ntf = [1 0 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '221';\r\ntf = [0 1 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '247';\r\ntf = [0 1 0 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '46189';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '2133423721';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '233296158667';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010101';\r\ntf = [0 0 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010103';\r\ntf = [0 1 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010107';\r\ntf = [0 0 0 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%\r\nn = '14300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = [1 1 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '14300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = [0 0 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '22100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = [0 1 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '221';\r\n\t\ttf = [0 1 1 0];\r\n\tcase 2\r\n\t\tn = '233296158667';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 3\r\n\t\tn = '46189';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 4\r\n\t\tn = '247';\r\n\t\ttf = [0 1 0 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '187';\r\n\t\ttf = [1 0 1 0];\r\n\tcase 2\r\n\t\tn = '143';\r\n\t\ttf = [1 1 0 0];\r\n\tcase 3\r\n\t\tn = '221';\r\n\t\ttf = [0 1 1 0];\r\n\tcase 4\r\n\t\tn = '233296158667';\r\n\t\ttf = [1 1 1 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '2133423721';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 2\r\n\t\tn = '46189';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 3\r\n\t\tn = '187';\r\n\t\ttf = [1 0 1 0];\r\n\tcase 4\r\n\t\tn = '247';\r\n\t\ttf = [0 1 0 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":73,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T04:18:06.000Z","updated_at":"2025-12-28T20:47:42.000Z","published_at":"2015-07-09T04:18:06.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\u003eDivisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u0026gt; 2392 is divisible by 13.\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\u003eFor 17, subtract five times the last digit from the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u0026gt; 3281 is divisible by 17.\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\u003eFor 19, add two times the last digit to the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u0026gt; 16863 is not divisible by 19.\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\u003eAnd, for 11, subtract the last digit from the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u0026gt; 269830 is divisible by 11.\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\u003eWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\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\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors from 20 to 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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:\"prime\"","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:\"prime\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"prime\"","","\"","prime","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f2f6928d5d0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f2f6928d490\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f2f6928c8b0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f2f6928dcb0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f2f6928dad0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f2f6928da30\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f2f6928d7b0\u003e":"tag:\"prime\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f2f6928d7b0\u003e":"tag:\"prime\""},"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:\"prime\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"prime\"","","\"","prime","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f2f6928d5d0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f2f6928d490\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f2f6928c8b0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f2f6928dcb0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f2f6928dad0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f2f6928da30\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f2f6928d7b0\u003e":"tag:\"prime\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f2f6928d7b0\u003e":"tag:\"prime\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":45201,"difficulty_rating":"easy"},{"id":44645,"difficulty_rating":"easy"},{"id":1673,"difficulty_rating":"easy"},{"id":60939,"difficulty_rating":"easy-medium"},{"id":42317,"difficulty_rating":"easy-medium"},{"id":44699,"difficulty_rating":"easy-medium"},{"id":54119,"difficulty_rating":"easy-medium"},{"id":45794,"difficulty_rating":"easy-medium"},{"id":45342,"difficulty_rating":"easy-medium"},{"id":3016,"difficulty_rating":"easy-medium"},{"id":42509,"difficulty_rating":"easy-medium"},{"id":60941,"difficulty_rating":"easy-medium"},{"id":896,"difficulty_rating":"easy-medium"},{"id":42454,"difficulty_rating":"easy-medium"},{"id":3001,"difficulty_rating":"easy-medium"},{"id":60944,"difficulty_rating":"easy-medium"},{"id":42510,"difficulty_rating":"easy-medium"},{"id":44305,"difficulty_rating":"easy-medium"},{"id":42914,"difficulty_rating":"easy-medium"},{"id":3003,"difficulty_rating":"easy-medium"},{"id":42453,"difficulty_rating":"easy-medium"},{"id":525,"difficulty_rating":"medium"},{"id":1722,"difficulty_rating":"medium"},{"id":42508,"difficulty_rating":"medium"},{"id":42455,"difficulty_rating":"medium"}]}}