{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.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":"2025-12-14T00: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":42918,"title":"Addition Partition","description":"You will be given two numbers, N and K.  Write a MATLAB function that will determine how many different unique ways you can have K numbers add up to N.  The numbers you use can be anything from 0-N, but no negatives and no fractions.  For example, five can be the sum of three numbers in five different ways:\r\n\r\n* 5+0+0\r\n* 4+1+0\r\n* 3+2+0\r\n* 3+1+1\r\n* 2+2+1\r\n\r\nOrder does not matter, so (5,0,0) is the same as (0,0,5) and (0,5,0).  Therefore, the output of your function num_sum(5,3) should be 5.  I don't need the different permutations, only how many there are.  Good luck!","description_html":"\u003cp\u003eYou will be given two numbers, N and K.  Write a MATLAB function that will determine how many different unique ways you can have K numbers add up to N.  The numbers you use can be anything from 0-N, but no negatives and no fractions.  For example, five can be the sum of three numbers in five different ways:\u003c/p\u003e\u003cul\u003e\u003cli\u003e5+0+0\u003c/li\u003e\u003cli\u003e4+1+0\u003c/li\u003e\u003cli\u003e3+2+0\u003c/li\u003e\u003cli\u003e3+1+1\u003c/li\u003e\u003cli\u003e2+2+1\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eOrder does not matter, so (5,0,0) is the same as (0,0,5) and (0,5,0).  Therefore, the output of your function num_sum(5,3) should be 5.  I don't need the different permutations, only how many there are.  Good luck!\u003c/p\u003e","function_template":"function y = num_sum(N,K)\r\n  y = N*K;\r\nend","test_suite":"%%\r\nN=5;K=3;\r\nassert(isequal(num_sum(N,K),5))\r\n%%\r\nN=7;K=4;\r\nassert(isequal(num_sum(N,K),11))\r\n%%\r\nN=7;K=3;\r\nassert(isequal(num_sum(N,K),8))\r\n%%\r\nN=15;K=6;\r\nassert(isequal(num_sum(N,K),110))\r\n%%\r\nN=20;K=4;\r\nassert(isequal(num_sum(N,K),108))\r\n%%\r\nN=12;K=9;\r\nassert(isequal(num_sum(N,K),73))\r\n%%\r\nN=13;K=3;\r\nassert(isequal(num_sum(N,K),21))\r\n%%\r\nN=12;K=2;\r\nassert(isequal(num_sum(N,K),7))\r\n%%\r\nN=15;K=2;\r\nassert(isequal(num_sum(N,K),8))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":28,"test_suite_updated_at":"2016-08-17T18:06:51.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-08-08T19:32:48.000Z","updated_at":"2025-12-05T13:02:15.000Z","published_at":"2016-08-08T19:34:19.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\u003eYou will be given two numbers, N and K. Write a MATLAB function that will determine how many different unique ways you can have K numbers add up to N. The numbers you use can be anything from 0-N, but no negatives and no fractions. For example, five can be the sum of three numbers in five different ways:\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\u003e5+0+0\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\u003e4+1+0\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\u003e3+2+0\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\u003e3+1+1\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\u003e2+2+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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOrder does not matter, so (5,0,0) is the same as (0,0,5) and (0,5,0). Therefore, the output of your function num_sum(5,3) should be 5. I don't need the different permutations, only how many there are. Good 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":58359,"title":"List numbers that cannot be expressed as the sum of fewer than four squares","description":"Lagrange proved that all positive integers can be expressed as the sum of four squares. For example, 27 = 16 + 9 + 1 + 1. However, it can also be expressed as the sum of three squares (9 + 9 + 9). In contrast, while 47 = 36 + 9 + 1 + 1, it cannot be expressed as a sum of fewer than four squares. \r\nWrite a function that produces the th member of the sequence of numbers that cannot be expressed as the sum of fewer than four non-zero squares. ","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: 114px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 57px; transform-origin: 407px 57px; vertical-align: baseline; \"\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: 384px 31.5px; text-align: left; transform-origin: 384px 31.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: 31.5167px 8px; transform-origin: 31.5167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eLagrange \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eproved\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: 326.733px 8px; transform-origin: 326.733px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e that all positive integers can be expressed as the sum of four squares. For example, 27 = 16 + 9 + 1 + 1. However, it can also be expressed as the sum of three squares (9 + 9 + 9). In contrast, while 47 = 36 + 9 + 1 + 1, it cannot be expressed as a sum of fewer than four squares. \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: 106.442px 8px; transform-origin: 106.442px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that produces the \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003en\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: 267.592px 8px; transform-origin: 267.592px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eth member of the sequence of numbers that cannot be expressed as the sum of fewer than four non-zero squares. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = foursquare(n)\r\n  y = sum((n-3:n).^2);\r\nend","test_suite":"%%\r\nassert(isequal(foursquare(8),55))\r\n\r\n%%\r\nassert(isequal(foursquare(18),112))\r\n\r\n%%\r\nassert(isequal(foursquare(80),487))\r\n\r\n%%\r\nassert(isequal(foursquare(88),535))\r\n\r\n%%\r\nassert(isequal(foursquare(180),1087))\r\n\r\n%%\r\nassert(isequal(foursquare(188),1136))\r\n\r\n%%\r\nassert(isequal(foursquare(808),4860))\r\n\r\n%%\r\nassert(isequal(foursquare(818),4924))\r\n\r\n%%\r\nassert(isequal(foursquare(881),5303))\r\n\r\n%%\r\nassert(isequal(foursquare(888),5343))\r\n\r\n%%\r\nassert(isequal(foursquare(8008),48064))\r\n\r\n%%\r\nassert(isequal(foursquare(8180),49088))\r\n\r\n%%\r\nassert(isequal(foursquare(8810),52879))\r\n\r\n%%\r\nassert(isequal(foursquare(8888),53343))\r\n\r\n%%\r\nassert(isequal(foursquare(80810),484879))\r\n\r\n%%\r\nassert(isequal(foursquare(888888),5333359))\r\n\r\n%%\r\nassert(isequal(foursquare(8080808),48484871))\r\n\r\n%%\r\nfiletext = fileread('foursquare.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert'); \r\nassert(~illegal)","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2023-05-21T15:05:27.000Z","deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2023-05-21T15:05:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2023-05-21T15:01:24.000Z","updated_at":"2023-05-21T15:05:27.000Z","published_at":"2023-05-21T15:05:27.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:t\u003eLagrange \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eproved\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:rPr/\u003e\u003cw:t\u003e that all positive integers can be expressed as the sum of four squares. For example, 27 = 16 + 9 + 1 + 1. However, it can also be expressed as the sum of three squares (9 + 9 + 9). In contrast, while 47 = 36 + 9 + 1 + 1, it cannot be expressed as a sum of fewer than four squares. \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 produces the \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\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003eth member of the sequence of numbers that cannot be expressed as the sum of fewer than four non-zero squares. \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":59701,"title":"Express numbers as the sum of a prime, a square, and a cube","description":"While traveling on an interstate highway, I noticed a sign that gave distances to three places. The distances were 3, 8, and 9 miles, or a prime, a perfect cube, and a perfect square. I then wondered whether it was possible to express integers (above a certain value) as the sum of a prime, a square, and a cube. For example, 11 can be expressed as , and 17 can be expressed as  or . \r\nWrite a function to list ways to express numbers as the sum of a prime, a square, and a cube. All three must be positive. The function should return a matrix the primes in the first column, the squares in the second, and the cubs in the third, and the rows should be sorted by the first column and then the second. Given an input of 11, the function should return [2 1 8], and given an input of 17, the function should return [5 4 8; 7 9 1]. If the input cannot be expressed in this way, return the empty vector [].\r\nOptional: Prove that all integers greater than 6 can be expressed as the sum of a prime, a square, and a cube.","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: 228.5px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 114.25px; transform-origin: 408px 114.25px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; 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 42px; text-align: left; transform-origin: 385px 42px; 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: 385px 8px; transform-origin: 385px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhile traveling on an interstate highway, I noticed a sign that gave distances to three places. The distances were 3, 8, and 9 miles, or a prime, a perfect cube, and a perfect square. I then wondered whether it was possible to express integers (above a certain value) as the sum of a prime, a square, and a cube. For example, 11 can be expressed as \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASEAAAAmCAYAAACLby0XAAAHYklEQVR4Xu1dTchuUxS+d07+RgwYmFy5RclPycSAUlKU6y99pfyV7kCEpC8DimRg4CckIZSBiSIZEPlJGRCDSzFgRMSc57nfWdrvPvvss8/Za++z3/OtU6v3u++7zz57PWvtZ6+99j77HjxglyFgCBgCCyJwcMFn26MNAUPAEDhgJGROYAgYAosiYCS0KPz2cEPAEDASMh8wBAyBRREwEloUfnv4PkPgCeh7NeRQp/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skVMQLrVJDwBBoGwEjobbtY60zBFaPgJHQ6k1sChoCbSNgJNS2fax1hsDqETASWr2JTUFDoG0EjITato+1zhBYPQJGQqs3sSloCLSNgJFQ2/ax1hkCq0fgP4vkKkWeHJZiAAAAAElFTkSuQmCC\" width=\"144.5\" height=\"19\" alt=\"2+1+8 = 2+1^2+2^3\" style=\"width: 144.5px; height: 19px;\"\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.74167px 8px; transform-origin: 3.74167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, and 17 can be expressed as \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASEAAAAmCAYAAACLby0XAAAHaElEQVR4Xu1dS+huUxS/d05eI7oxMLmiKHmUGEhuKRko73QH8ipJIgz07w7cupKBgUdIQigDE+WRAZFH6ipigCJdIyLm/H51lvbdZ599Xmvvs/e+69Tq+9/vO98+e/322r+99lrr23f3LrsMAUPAENgQgd0bPtsebQgYAobALiMhMwJDwBDYFAEjoU3ht4cbAoaAkZDZgCFgCGyKgJHQpvDbw48xBA5B36shezu938TrXZA/GsTheui04+j6Hv6+MaSrkVCDo28qFYnAG+jViZAXISdB7u0m6D94PaMxIiIBPQk5APkJcj/kSsjnkIv90TESKtJerVONIXAB9HkKcpVDNifj728gp0IegRxsSOfPoMvNkB8dnY50up7iE+5aEroTDb7vPawhLE2VjRBoza64DfsKQm/IvZ7FP26HPAe5YyOstR9Lcj0T8qXXMInpdMg5S0hIGCzU2e/x5lnaWiRujyB9AtkDOT7xszSaZ38fgpwLOaFr8Gy8fguhy+sbtsYzc7RRs13JmLjxnd8A2seQOTEektMDkJI9IQ1d2cbPna7P+MY15glxRXo6YpElg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zTkxY135f15qxzpDfVDVdQkJsVOSlZmjcCwoORXsqc/js1gmHioCW0NCQpRT+xu6b66RcnVlIkAI1fdiWiKiJXa1xZiExlXq3FIkbfyFOqf9Jdd1KQlNKaTzO5+LhOTMlkvQgdA5LTWR0NAPHGXfLduzNVuzNQat/d0ldlUCCUkJSKiIUROjJnVdSkIp3Fyt7diSgZrqYcUMShsTcXnZt9DPNlwi0k4SaE6cOW1pY6jdXkgXqXxOTUBjOFar61oSmru1iAFpJHQ0OlJhGiNI8ZT4zTmZqtIC06K5TCQtu0o9MUshIOJXra5LSUiMv+Ts2BDhrdmO5fSEpvTTDea2QELadpVyYk4hIKamcx3dWq2uS0hIKnmZqdGs1NXyhMbc1imTe6yN0OfaRuD+4r93Gl3XAfeZtR8RmsKutMdExl2OuNiPN4ZOkpDamKHY5BIby7kIZtM1REISQGacIQSyZGtuw+eav30xEuqb2BG8FTv+s6aT+bawqxQk5BbjDR1xwzOkdyD8vWWuExOr1TVEQmL4MiXI9E9ACOx9EFZ43grRPoTJSKhPQm7w2d/6iqeU6rd82iv1FnalPTH9rGQMI8by5PeK2ljm8MSz6RoiISmlZ72DpIDpFf0CeQnCCsgU+1wjobCpusdrcgHgOMjF8YidWZPD+Kc+Ywu70iQhKYB1q9Zjuueu36pW1yUxoalGN/c+KfbiSWzaXtbcviy5Xw6V4nd7/63JkgbtO6sROJbGpFpdSyKh1RZnDRgChkB9CBgJ1Tdm1mNDoCkEjISaGk5TxhCoDwEjofrGzHpsCDSFgJFQU8NpyhgC9SFgJFTfmFmPDYGmEDASamo4TRlDoD4EjITqGzPrsSHQFAL/AfbuRkUnfj12AAAAAElFTkSuQmCC\" width=\"144.5\" height=\"19\" alt=\"5+4+8 = 5 + 2^2+2^3\" style=\"width: 144.5px; height: 19px;\"\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: 10.1083px 8px; transform-origin: 10.1083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e or \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASEAAAAmCAYAAACLby0XAAAHSklEQVR4Xu1dS8h2UxT+/zm5jRhQ/ANKUXJJGZBLiZSB+0DIrSSJ+Af6M/gVycDAJUmKUExIkQxIuaSEYoBiwIiIOc9TZ2l/+93nnL3PXnuffc5Zp1bv+72dy17Pes6z1157n/Pt32ebIWAIGAIzIrB/xmvbpQ0BQ8AQ2GciZCQwBAyBWREwEZoVfru4IWAImAgZBwwBQ2BWBEyEZoXfLr4xBB6Hv1fCTu38fgOfd8H+WCEO18KnQ46v7+P79SFfTYRWGH1zqUkEXkerjoa9CDsGdm93g/6Dz5NWJkQUoKdgj8J+gt0PuxT2Gew8PzomQk3y1Rq1MgTOhj9Pwy53xOZYfP8WdjzsIOyxFfn8KXy5Efaj49Ovna/H+YJrIrSiyJsrzSLAYdiXMGZD7vYc/rgd9jzsjmZbn9YwiuspsC+8wyhMJ8JOjxWh77CjjFvHmsBxLdOvVreH0bCrusYdhU/a2zD+vrSxOAP8EOwm2AmtAj7QrrXwinGgaJBX53b+ft/x6sGEuFCcHoAtJROayj8e93Pn67M+PqFMiKnj5wlAXod9fYVPOLzYrlTjd7qzX4FPSQ05Nn2z+/22RtvugyLBZxHzCBjrCEcWQ67MidfCK8biExg7adY4uIkQ8TvF6LRICHnfXAM7B+ZnDpGnqLJbDv947DNdK4PJSkiECMwFMCkq9Xn5XncztFhUc4kSEklmQYc7xw7g0x27VolqwkUYuKthf8KYunNbogitgVfEntncL7C7Hd7IjUZB4cbOYqfHD8ScdZKPYS2PJHL4x/vsHhjrXtyCoyZfhCRtuggHDCkzG/Za30kDYMf8xDEjN7+gFXOsv4+kuUMzD3/jIGYVnDq8bMpFvGOk+Pi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mJDNJJYGtIULyICXrQxRU9013uWSoQfgiPVGu4xnHl+ZVjZiEakL8LXfdTyqsNXwtwr+YTMhNmWMLuKkAcv/SIsRFVFwsJe+B0RQgtn+xJJgSLIVjavBKOyas95wB+wgWenkZh/nkldYQPwVmbV9D155NhCRl1irg9gFbUoToA5/e5cYVqyVepVmaBG4WRz923tWbwtgG9q3BK+2YyKs6CJ+77IMvrucsLF9fyuUfe15VUQlrbV/9ZhfjX0wmJCnzziP4yuBqixBnwLiITNYE8eVRHE5qPfXvu1+KBDzvrV0Py2GkbCyqU1C5RF7zaWzlsPaergavtGPi/xsbOsdhPV9d+tbMcdD2VQJXnH8xIlSLlPJSM76JLfdVl/LyKZLjg0o9k7xUinjt/FuTWiDadfYgsKWYLNbXlkTI7h9DwBDYIAImQhsMurlsCLSEgIlQS9GwthgCG0TARGiDQTeXDYGWEDARaika1hZDYIMImAhtMOjmsiHQEgImQi1Fw9piCGwQAROhDQbdXDYEWkLgP1z7G0XU12krAAAAAElFTkSuQmCC\" width=\"144.5\" height=\"19\" alt=\"7+9+1 = 7+3^2+1^3\" style=\"width: 144.5px; height: 19px;\"\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=\"\"\u003e. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 105.5px; 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 52.75px; text-align: left; transform-origin: 385px 52.75px; 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: 385px 8px; transform-origin: 385px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to list ways to express numbers as the sum of a prime, a square, and a cube. All three must be positive. The function should return a matrix the primes in the first column, the squares in the second, and the cubs in the third, and the rows should be sorted by the first column and then the second. Given an input of 11, the function should return [2 1 8], and given an input of 17, the function should return [5 4 8; 7 9 1]. If the input cannot be expressed in this way, return the empty 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.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; perspective-origin: 3.85px 8.5px; transform-origin: 3.85px 8.5px; \"\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: 3.88333px 8px; transform-origin: 3.88333px 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: 341.117px 8px; transform-origin: 341.117px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOptional: Prove that all integers greater than 6 can be expressed as the sum of a prime, a square, and a cube.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function v = primeSquareCube(n)\r\n  v = [primes(n) n^2 n^3];\r\nend","test_suite":"%%\r\nn = 11;\r\nv = primeSquareCube(n);\r\nv_correct = [2 1 8];\r\nassert(isequal(v,v_correct))\r\n\r\n%%\r\nn = 17;\r\nv = primeSquareCube(n);\r\nv_correct = [5 4 8; 7 9 1];\r\nassert(isequal(v,v_correct))\r\n\r\n%%\r\nn = 58;\r\nv = primeSquareCube(n);\r\nv_correct = [41 9 8; 41 16 1; 53 4 1];\r\nassert(isequal(v,v_correct))\r\n\r\n%%\r\nn = 82;\r\nv = primeSquareCube(n);\r\nv_correct = [2 16 64; 17 1 64; 17 64 1; 19 36 27; 73 1 8];\r\nassert(isequal(v,v_correct))\r\n\r\n%%\r\nn = 56342;\r\nv = primeSquareCube(n);\r\nsum_correct = [24203820 13786001 8886723];\r\nN_correct = 832;\r\nmax_correct = 56333;\r\nassert(isequal(sum(v),sum_correct))\r\nassert(isequal(size(v,1),N_correct))\r\nassert(isequal(max(v,[],'all'),max_correct))\r\n\r\n%%\r\nn = 4938523;\r\nv = primeSquareCube(n);\r\nsum_correct = [53237782818 28599306108 19254476884];\r\nN_correct = 20470;\r\nmax_correct = 4938473;\r\nassert(isequal(sum(v),sum_correct))\r\nassert(isequal(size(v,1),N_correct))\r\nassert(isequal(max(v,[],'all'),max_correct))\r\n\r\n%%\r\na = NaN(1,10000);\r\nfor n = 1:10000\r\n    v = primeSquareCube(n);\r\n    a(n) = size(v,1);\r\n    if a(n)\u003e0\r\n        assert(all(sum(v,2)==n))\r\n        p = v(:,1); s = v(:,2); c = v(:,3);\r\n        assert(all(isprime(p)))\r\n        assert(all(sqrt(s)==floor(sqrt(s))))\r\n        assert(all(nthroot(c,3)==floor(nthroot(c,3))))\r\n    end\r\nend\r\nu = unique(a);\r\nh = groupcounts(a')';\r\na100_correct = [0 0 0 1 1 0 2 1 1 1 1 3 2 2 3 2 2 1 4 3 2 4 2 3 2 2 2 5 4 3 5 1 5 4 4 5 2 4 6 5 5 3 5 3 4 7 5 6 5 5 3 4 5 6 8 4 6 3 5 6 4 5 6 5 6 4 7 7 6 9 6 5 7 7 7 10 4 9 7 7 8 5 8 10 9 5 8 7 7 6 10 7 8 9 8 10 7 5 9 7];\r\nsum_correct = 1232200;\r\nu_correct = [0:255 258:261 264 273 276];\r\nh_correct = [4 8 11 9 14 19 11 17 16 18 24 25 23 14 28 18 28 29 22 26 25 26 36 26 25 24 31 27 32 37 27 31 31 43 38 32 29 27 31 39 38 23 34 34 47 50 42 38 34 34 37 37 32 38 45 53 39 34 43 45 23 47 32 40 38 54 41 44 38 47 34 49 50 32 53 54 39 43 53 51 45 26 43 52 62 50 59 48 41 45 55 48 41 48 36 48 41 59 57 48 51 48 50 36 53 61 52 55 49 49 46 48 50 52 50 71 55 47 58 53 60 48 52 70 47 51 61 47 67 53 62 63 50 52 52 59 47 55 62 58 59 56 44 49 65 58 54 61 60 58 70 61 58 49 63 55 53 59 54 48 66 53 47 53 56 64 69 51 70 52 65 64 75 53 55 59 56 63 61 53 58 69 61 63 52 48 54 46 49 59 50 61 34 53 38 45 46 33 44 26 31 35 47 40 39 42 31 30 34 27 32 35 35 30 30 23 24 29 21 12 19 26 15 23 20 15 17 12 15 12 8 13 15 9 10 9 13 10 6 6 8 4 5 3 4 3 5 6 7 2 1 4 3 1 2 4 2 1 1 1 1 1 1];\r\nassert(isequal(a(1:100),a100_correct))\r\nassert(isequal(sum(a),sum_correct))\r\nassert(isequal(u,u_correct))\r\nassert(isequal(h,h_correct))\r\n\r\n%%\r\nfiletext = fileread('primeSquareCube.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'regexp'); \r\nassert(~illegal)","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":46909,"edited_by":46909,"edited_at":"2025-07-16T16:58:51.000Z","deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2024-03-16T13:48:17.000Z","updated_at":"2025-07-26T04:58:48.000Z","published_at":"2024-03-16T13:51:57.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:t\u003eWhile traveling on an interstate highway, I noticed a sign that gave distances to three places. The distances were 3, 8, and 9 miles, or a prime, a perfect cube, and a perfect square. I then wondered whether it was possible to express integers (above a certain value) as the sum of a prime, a square, and a cube. For example, 11 can be expressed as \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\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"2+1+8 = 2+1^2+2^3\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e2+1+8 = 2+1^2+2^3\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e, and 17 can be expressed as \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\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"5+4+8 = 5 + 2^2+2^3\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e5+4+8 = 5 + 2^2+2^3\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e or \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\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"7+9+1 = 7+3^2+1^3\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e7+9+1 = 7+3^2+1^3\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=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to list ways to express numbers as the sum of a prime, a square, and a cube. All three must be positive. The function should return a matrix the primes in the first column, the squares in the second, and the cubs in the third, and the rows should be sorted by the first column and then the second. Given an input of 11, the function should return [2 1 8], and given an input of 17, the function should return [5 4 8; 7 9 1]. If the input cannot be expressed in this way, return the empty vector \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[\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\u003eOptional: Prove that all integers greater than 6 can be expressed as the sum of a prime, a square, and a cube.\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":1873,"title":"Break it up!  Break it up!","description":"You have N pennies.  Write a Matlab script that will reveal how many different ways you can break up those pennies.  For example, with 5 pennies, there are seven different ways you can divide them:\r\n\r\n* (1,1,1,1,1)\r\n* (2,1,1,1)\r\n* (2,2,1)\r\n* (3,2)\r\n* (3,1,1)\r\n* (4,1)\r\n* (5)\r\n\r\nThe order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2).  You can assume that N will always be a positive integer.","description_html":"\u003cp\u003eYou have N pennies.  Write a Matlab script that will reveal how many different ways you can break up those pennies.  For example, with 5 pennies, there are seven different ways you can divide them:\u003c/p\u003e\u003cul\u003e\u003cli\u003e(1,1,1,1,1)\u003c/li\u003e\u003cli\u003e(2,1,1,1)\u003c/li\u003e\u003cli\u003e(2,2,1)\u003c/li\u003e\u003cli\u003e(3,2)\u003c/li\u003e\u003cli\u003e(3,1,1)\u003c/li\u003e\u003cli\u003e(4,1)\u003c/li\u003e\u003cli\u003e(5)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2).  You can assume that N will always be a positive integer.\u003c/p\u003e","function_template":"function y = partitions(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;y_correct = 1;assert(isequal(partitions(x),y_correct))\r\n%%\r\nx = 5;y_correct = 7;assert(isequal(partitions(x),y_correct))\r\n%%\r\nx = 50;y_correct = 204226;assert(isequal(partitions(x),y_correct))\r\n%%\r\nassert(isequal(partitions(partitions(partitions(partitions(5)))),476715857290));\r\n%%\r\nassert(isequal(partitions(partitions(partitions(6))),526823));\r\n%%\r\nassert(isequal(partitions(partitions(12)),10619863));\r\n%%\r\nassert(isequal(partitions(199),3646072432125))\r\n%%\r\nP=arrayfun(@(x) partitions(x),10:10:100);\r\ny_correct=[42 627 5604 37338 204226 966467 4087968 15796476 56634173 190569292];\r\nassert(all(isequal(P,y_correct)))","published":true,"deleted":false,"likes_count":4,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":81,"test_suite_updated_at":"2016-08-19T11:36:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-13T18:34:19.000Z","updated_at":"2026-04-03T20:00:35.000Z","published_at":"2013-09-13T18:34:19.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\u003eYou have N pennies. Write a Matlab script that will reveal how many different ways you can break up those pennies. For example, with 5 pennies, there are seven different ways you can divide them:\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\u003e(1,1,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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(2,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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(2,2,1)\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\u003e(3,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\u003e(3,1,1)\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\u003e(4,1)\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\u003e(5)\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 order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2). You can assume that N will always be a positive integer.\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":42918,"title":"Addition Partition","description":"You will be given two numbers, N and K.  Write a MATLAB function that will determine how many different unique ways you can have K numbers add up to N.  The numbers you use can be anything from 0-N, but no negatives and no fractions.  For example, five can be the sum of three numbers in five different ways:\r\n\r\n* 5+0+0\r\n* 4+1+0\r\n* 3+2+0\r\n* 3+1+1\r\n* 2+2+1\r\n\r\nOrder does not matter, so (5,0,0) is the same as (0,0,5) and (0,5,0).  Therefore, the output of your function num_sum(5,3) should be 5.  I don't need the different permutations, only how many there are.  Good luck!","description_html":"\u003cp\u003eYou will be given two numbers, N and K.  Write a MATLAB function that will determine how many different unique ways you can have K numbers add up to N.  The numbers you use can be anything from 0-N, but no negatives and no fractions.  For example, five can be the sum of three numbers in five different ways:\u003c/p\u003e\u003cul\u003e\u003cli\u003e5+0+0\u003c/li\u003e\u003cli\u003e4+1+0\u003c/li\u003e\u003cli\u003e3+2+0\u003c/li\u003e\u003cli\u003e3+1+1\u003c/li\u003e\u003cli\u003e2+2+1\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eOrder does not matter, so (5,0,0) is the same as (0,0,5) and (0,5,0).  Therefore, the output of your function num_sum(5,3) should be 5.  I don't need the different permutations, only how many there are.  Good luck!\u003c/p\u003e","function_template":"function y = num_sum(N,K)\r\n  y = N*K;\r\nend","test_suite":"%%\r\nN=5;K=3;\r\nassert(isequal(num_sum(N,K),5))\r\n%%\r\nN=7;K=4;\r\nassert(isequal(num_sum(N,K),11))\r\n%%\r\nN=7;K=3;\r\nassert(isequal(num_sum(N,K),8))\r\n%%\r\nN=15;K=6;\r\nassert(isequal(num_sum(N,K),110))\r\n%%\r\nN=20;K=4;\r\nassert(isequal(num_sum(N,K),108))\r\n%%\r\nN=12;K=9;\r\nassert(isequal(num_sum(N,K),73))\r\n%%\r\nN=13;K=3;\r\nassert(isequal(num_sum(N,K),21))\r\n%%\r\nN=12;K=2;\r\nassert(isequal(num_sum(N,K),7))\r\n%%\r\nN=15;K=2;\r\nassert(isequal(num_sum(N,K),8))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":28,"test_suite_updated_at":"2016-08-17T18:06:51.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-08-08T19:32:48.000Z","updated_at":"2025-12-05T13:02:15.000Z","published_at":"2016-08-08T19:34:19.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\u003eYou will be given two numbers, N and K. Write a MATLAB function that will determine how many different unique ways you can have K numbers add up to N. The numbers you use can be anything from 0-N, but no negatives and no fractions. For example, five can be the sum of three numbers in five different ways:\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\u003e5+0+0\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\u003e4+1+0\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\u003e3+2+0\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\u003e3+1+1\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\u003e2+2+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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOrder does not matter, so (5,0,0) is the same as (0,0,5) and (0,5,0). Therefore, the output of your function num_sum(5,3) should be 5. I don't need the different permutations, only how many there are. Good 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":58359,"title":"List numbers that cannot be expressed as the sum of fewer than four squares","description":"Lagrange proved that all positive integers can be expressed as the sum of four squares. For example, 27 = 16 + 9 + 1 + 1. However, it can also be expressed as the sum of three squares (9 + 9 + 9). In contrast, while 47 = 36 + 9 + 1 + 1, it cannot be expressed as a sum of fewer than four squares. \r\nWrite a function that produces the th member of the sequence of numbers that cannot be expressed as the sum of fewer than four non-zero squares. ","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: 114px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 57px; transform-origin: 407px 57px; vertical-align: baseline; \"\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: 384px 31.5px; text-align: left; transform-origin: 384px 31.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: 31.5167px 8px; transform-origin: 31.5167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eLagrange \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eproved\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: 326.733px 8px; transform-origin: 326.733px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e that all positive integers can be expressed as the sum of four squares. For example, 27 = 16 + 9 + 1 + 1. However, it can also be expressed as the sum of three squares (9 + 9 + 9). In contrast, while 47 = 36 + 9 + 1 + 1, it cannot be expressed as a sum of fewer than four squares. \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: 106.442px 8px; transform-origin: 106.442px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that produces the \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003en\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: 267.592px 8px; transform-origin: 267.592px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eth member of the sequence of numbers that cannot be expressed as the sum of fewer than four non-zero squares. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = foursquare(n)\r\n  y = sum((n-3:n).^2);\r\nend","test_suite":"%%\r\nassert(isequal(foursquare(8),55))\r\n\r\n%%\r\nassert(isequal(foursquare(18),112))\r\n\r\n%%\r\nassert(isequal(foursquare(80),487))\r\n\r\n%%\r\nassert(isequal(foursquare(88),535))\r\n\r\n%%\r\nassert(isequal(foursquare(180),1087))\r\n\r\n%%\r\nassert(isequal(foursquare(188),1136))\r\n\r\n%%\r\nassert(isequal(foursquare(808),4860))\r\n\r\n%%\r\nassert(isequal(foursquare(818),4924))\r\n\r\n%%\r\nassert(isequal(foursquare(881),5303))\r\n\r\n%%\r\nassert(isequal(foursquare(888),5343))\r\n\r\n%%\r\nassert(isequal(foursquare(8008),48064))\r\n\r\n%%\r\nassert(isequal(foursquare(8180),49088))\r\n\r\n%%\r\nassert(isequal(foursquare(8810),52879))\r\n\r\n%%\r\nassert(isequal(foursquare(8888),53343))\r\n\r\n%%\r\nassert(isequal(foursquare(80810),484879))\r\n\r\n%%\r\nassert(isequal(foursquare(888888),5333359))\r\n\r\n%%\r\nassert(isequal(foursquare(8080808),48484871))\r\n\r\n%%\r\nfiletext = fileread('foursquare.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert'); \r\nassert(~illegal)","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2023-05-21T15:05:27.000Z","deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2023-05-21T15:05:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2023-05-21T15:01:24.000Z","updated_at":"2023-05-21T15:05:27.000Z","published_at":"2023-05-21T15:05:27.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:t\u003eLagrange \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eproved\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:rPr/\u003e\u003cw:t\u003e that all positive integers can be expressed as the sum of four squares. For example, 27 = 16 + 9 + 1 + 1. However, it can also be expressed as the sum of three squares (9 + 9 + 9). In contrast, while 47 = 36 + 9 + 1 + 1, it cannot be expressed as a sum of fewer than four squares. \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 produces the \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\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003eth member of the sequence of numbers that cannot be expressed as the sum of fewer than four non-zero squares. \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":59701,"title":"Express numbers as the sum of a prime, a square, and a cube","description":"While traveling on an interstate highway, I noticed a sign that gave distances to three places. The distances were 3, 8, and 9 miles, or a prime, a perfect cube, and a perfect square. I then wondered whether it was possible to express integers (above a certain value) as the sum of a prime, a square, and a cube. For example, 11 can be expressed as , and 17 can be expressed as  or . \r\nWrite a function to list ways to express numbers as the sum of a prime, a square, and a cube. All three must be positive. The function should return a matrix the primes in the first column, the squares in the second, and the cubs in the third, and the rows should be sorted by the first column and then the second. Given an input of 11, the function should return [2 1 8], and given an input of 17, the function should return [5 4 8; 7 9 1]. If the input cannot be expressed in this way, return the empty vector [].\r\nOptional: Prove that all integers greater than 6 can be expressed as the sum of a prime, a square, and a cube.","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: 228.5px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 114.25px; transform-origin: 408px 114.25px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; 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 42px; text-align: left; transform-origin: 385px 42px; 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: 385px 8px; transform-origin: 385px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhile traveling on an interstate highway, I noticed a sign that gave distances to three places. The distances were 3, 8, and 9 miles, or a prime, a perfect cube, and a perfect square. I then wondered whether it was possible to express integers (above a certain value) as the sum of a prime, a square, and a cube. For example, 11 can be expressed as \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASEAAAAmCAYAAACLby0XAAAHYklEQVR4Xu1dTchuUxS+d07+RgwYmFy5RclPycSAUlKU6y99pfyV7kCEpC8DimRg4CckIZSBiSIZEPlJGRCDSzFgRMSc57nfWdrvPvvss8/Za++z3/OtU6v3u++7zz57PWvtZ6+99j77HjxglyFgCBgCCyJwcMFn26MNAUPAEDhgJGROYAgYAosiYCS0KPz2cEPAEDASMh8wBAyBRREwEloUfnv4PkPgCeh7NeRQp/fb+LwL8scKcTgCnXYdXT/A3zeGdDUSWqH1TaUmEXgLrToZ8jLkFMjRroP+g8+zVkZEJKCnIY9CfoLcC7kC8gXkEt86RkJN+qs1amUIXAh9noFc5ZDNqfj7W8jpkIcgj69I58+hy82QHx2dfu10Pc0nXCOhFVneVGkWAU7DvoYwGnKv5/GP2yEvQO5otvXTGkZyPRvylXcbielMyOGpJHQnbtiBXNxVyNDxM8jDgYdMa2r90gTnAcgtkDPqP372E6Xd56GGk7pazsXndxCGvL5jz35QxRvNr/bAJjndB2k5EhL/c3NZv6HNn0BS81ms4+dO1+d8PxuKhHjTew75hPzzhi3pAAIiATsBQiI9sWKHy3kUw/iPOsLxw1uSz/WQbRpF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ChmDUSU41dL2MS1v4ZfpfrT0rpKO2VPn/tCbqoOvXJTIiFJLA1tYhxrhJHQHkJTSGjoBUeZd8v0LGdqNma30r/n+tXSHXO/kVDOgBH0pVQSkndIcpKhY85s07FNhCTkHVoAcIlIc9PomJ00fy/tVzWmKDVJKIZ9DV1ll/ecmdBg21NIqLSjSOOMhDbNJDtMY1NQiZR455SVqhYS0zX8qkbH3C8kVISA6LhjJJTiKFx+0zie0khok4SEKGIkJJ1s20ioll8ZCenErSkENJsHYiQUXdt3dOOrA091uY4clY2ENtGTfRj8tncaXVfU7WTbckRoTb8yEsrpkXv3yoCxE+njYtNL5wQksfOEuLmIF8/CHbp4dixPS9N4dcNIqI8yl61jx39u28l84qy1/MpIKI+E3I2HcqSPXyPPy96FfAyZdTpkiITEUQ4ltl/rVLiSJOS/hzUUWSSqHCxWwuHd5LP/zo1ESjw8XGWpNEf5hHuX8KsSNnFVreFXCdAeL6Ktq78CG2sHUwY8Z2jjiI7UhodISN7fSakj5WS1lHpYpgQJ0TC3dZ3U3W3MdnP7PE8t1HqTWdsJBDf3eE1u8f/FAfQV/D101EIq7rXKLeFXpWxS069S7aOpK1dm+ZKt22di7cjaqzaWmE4FQKOcbIDi6Y0tHnU5pqMcKsVyvf/WZOxm+70IAvvJJlura0skVMQLrVJDwBBoGwEjobbtY60zBFaPgJHQ6k1sChoCbSNgJNS2fax1hsDqETASWr2JTUFDoG0EjITato+1zhBYPQJGQqs3sSloCLSNgJFQ2/ax1hkCq0fgP4vkKkWeHJZiAAAAAElFTkSuQmCC\" width=\"144.5\" height=\"19\" alt=\"2+1+8 = 2+1^2+2^3\" style=\"width: 144.5px; height: 19px;\"\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.74167px 8px; transform-origin: 3.74167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, and 17 can be expressed as \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASEAAAAmCAYAAACLby0XAAAHaElEQVR4Xu1dS+huUxS/d05eI7oxMLmiKHmUGEhuKRko73QH8ipJIgz07w7cupKBgUdIQigDE+WRAZFH6ipigCJdIyLm/H51lvbdZ599Xmvvs/e+69Tq+9/vO98+e/322r+99lrr23f3LrsMAUPAENgQgd0bPtsebQgYAobALiMhMwJDwBDYFAEjoU3ht4cbAoaAkZDZgCFgCGyKgJHQpvDbw48xBA5B36shezu938TrXZA/GsTheui04+j6Hv6+MaSrkVCDo28qFYnAG+jViZAXISdB7u0m6D94PaMxIiIBPQk5APkJcj/kSsjnkIv90TESKtJerVONIXAB9HkKcpVDNifj728gp0IegRxsSOfPoMvNkB8dnY50up7iE+5aEroTDb7vPawhLE2VjRBoza64DfsKQm/IvZ7FP26HPAe5YyOstR9Lcj0T8qXXMInpdMg5S0hIGCzU2e/x5lnaWiRujyB9AtkDOT7xszSaZ38fgpwLOaFr8Gy8fguhy+sbtsYzc7RRs13JmLjxnd8A2seQOTEektMDkJI9IQ1d2cbPna7P+MY15glxRXo6YpElgzfUbVl9uBcvnYToxn/YEY7v3pJ8roPUuIrWbFcck7ch3EaFLtrVeRB3KzJkizKGF+IG33PIsRCMPUNDVxKQcAhjRb1rjIS4WpHdXxjoLSPeNV0E4fWuw6WTkKwe7O7lA0b6Hd5npuUGSE0eUc12Rczpkb4C+aCzpWvxehPkuJm2JTgEJ2cBE2utrg9Dh3sgQtjMBvZ0jZEQV6vHIxNAGyPuGXn5K77Wc7hPPQz5tZu42iQkwce/0P4+hU6LtxDrp7jzwcFV6EOKJnLalfaYyKS6JrAouIFm4sZtWW/r4QBKHB6FXAqZ4jWNjUWpusp2jttOXpwbRzkvMRIiKZDxc8V8/u06mco1pT4kiK8hBESbhJiCfFexXSEYw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Mbc1imTe6yN0OfaRuD+4r93Gl3XAfeZtR8RmsKutMdExl2OuNiPN4ZOkpDamKHY5BIby7kIZtM1REISQGacIQSyZGtuw+eav30xEuqb2BG8FTv+s6aT+bawqxQk5BbjDR1xwzOkdyD8vWWuExOr1TVEQmL4MiXI9E9ACOx9EFZ43grRPoTJSKhPQm7w2d/6iqeU6rd82iv1FnalPTH9rGQMI8by5PeK2ljm8MSz6RoiISmlZ72DpIDpFf0CeQnCCsgU+1wjobCpusdrcgHgOMjF8YidWZPD+Kc+Ywu70iQhKYB1q9Zjuueu36pW1yUxoalGN/c+KfbiSWzaXtbcviy5Xw6V4nd7/63JkgbtO6sROJbGpFpdSyKh1RZnDRgChkB9CBgJ1Tdm1mNDoCkEjISaGk5TxhCoDwEjofrGzHpsCDSFgJFQU8NpyhgC9SFgJFTfmFmPDYGmEDASamo4TRlDoD4EjITqGzPrsSHQFAL/AfbuRkUnfj12AAAAAElFTkSuQmCC\" width=\"144.5\" height=\"19\" alt=\"5+4+8 = 5 + 2^2+2^3\" style=\"width: 144.5px; height: 19px;\"\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: 10.1083px 8px; transform-origin: 10.1083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e or \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASEAAAAmCAYAAACLby0XAAAHSklEQVR4Xu1dS8h2UxT+/zm5jRhQ/ANKUXJJGZBLiZSB+0DIrSSJ+Af6M/gVycDAJUmKUExIkQxIuaSEYoBiwIiIOc9TZ2l/+93nnL3PXnuffc5Zp1bv+72dy17Pes6z1157n/Pt32ebIWAIGAIzIrB/xmvbpQ0BQ8AQ2GciZCQwBAyBW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o9k7xUinjt/FuTWiDadfYgsKWYLNbXlkTI7h9DwBDYIAImQhsMurlsCLSEgIlQS9GwthgCG0TARGiDQTeXDYGWEDARaika1hZDYIMImAhtMOjmsiHQEgImQi1Fw9piCGwQAROhDQbdXDYEWkLgP1z7G0XU12krAAAAAElFTkSuQmCC\" width=\"144.5\" height=\"19\" alt=\"7+9+1 = 7+3^2+1^3\" style=\"width: 144.5px; height: 19px;\"\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=\"\"\u003e. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 105.5px; 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 52.75px; text-align: left; transform-origin: 385px 52.75px; 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: 385px 8px; transform-origin: 385px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to list ways to express numbers as the sum of a prime, a square, and a cube. All three must be positive. The function should return a matrix the primes in the first column, the squares in the second, and the cubs in the third, and the rows should be sorted by the first column and then the second. Given an input of 11, the function should return [2 1 8], and given an input of 17, the function should return [5 4 8; 7 9 1]. If the input cannot be expressed in this way, return the empty 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.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; perspective-origin: 3.85px 8.5px; transform-origin: 3.85px 8.5px; \"\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: 3.88333px 8px; transform-origin: 3.88333px 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: 341.117px 8px; transform-origin: 341.117px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOptional: Prove that all integers greater than 6 can be expressed as the sum of a prime, a square, and a cube.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function v = primeSquareCube(n)\r\n  v = [primes(n) n^2 n^3];\r\nend","test_suite":"%%\r\nn = 11;\r\nv = primeSquareCube(n);\r\nv_correct = [2 1 8];\r\nassert(isequal(v,v_correct))\r\n\r\n%%\r\nn = 17;\r\nv = primeSquareCube(n);\r\nv_correct = [5 4 8; 7 9 1];\r\nassert(isequal(v,v_correct))\r\n\r\n%%\r\nn = 58;\r\nv = primeSquareCube(n);\r\nv_correct = [41 9 8; 41 16 1; 53 4 1];\r\nassert(isequal(v,v_correct))\r\n\r\n%%\r\nn = 82;\r\nv = primeSquareCube(n);\r\nv_correct = [2 16 64; 17 1 64; 17 64 1; 19 36 27; 73 1 8];\r\nassert(isequal(v,v_correct))\r\n\r\n%%\r\nn = 56342;\r\nv = primeSquareCube(n);\r\nsum_correct = [24203820 13786001 8886723];\r\nN_correct = 832;\r\nmax_correct = 56333;\r\nassert(isequal(sum(v),sum_correct))\r\nassert(isequal(size(v,1),N_correct))\r\nassert(isequal(max(v,[],'all'),max_correct))\r\n\r\n%%\r\nn = 4938523;\r\nv = primeSquareCube(n);\r\nsum_correct = [53237782818 28599306108 19254476884];\r\nN_correct = 20470;\r\nmax_correct = 4938473;\r\nassert(isequal(sum(v),sum_correct))\r\nassert(isequal(size(v,1),N_correct))\r\nassert(isequal(max(v,[],'all'),max_correct))\r\n\r\n%%\r\na = NaN(1,10000);\r\nfor n = 1:10000\r\n    v = primeSquareCube(n);\r\n    a(n) = size(v,1);\r\n    if a(n)\u003e0\r\n        assert(all(sum(v,2)==n))\r\n        p = v(:,1); s = v(:,2); c = v(:,3);\r\n        assert(all(isprime(p)))\r\n        assert(all(sqrt(s)==floor(sqrt(s))))\r\n        assert(all(nthroot(c,3)==floor(nthroot(c,3))))\r\n    end\r\nend\r\nu = unique(a);\r\nh = groupcounts(a')';\r\na100_correct = [0 0 0 1 1 0 2 1 1 1 1 3 2 2 3 2 2 1 4 3 2 4 2 3 2 2 2 5 4 3 5 1 5 4 4 5 2 4 6 5 5 3 5 3 4 7 5 6 5 5 3 4 5 6 8 4 6 3 5 6 4 5 6 5 6 4 7 7 6 9 6 5 7 7 7 10 4 9 7 7 8 5 8 10 9 5 8 7 7 6 10 7 8 9 8 10 7 5 9 7];\r\nsum_correct = 1232200;\r\nu_correct = [0:255 258:261 264 273 276];\r\nh_correct = [4 8 11 9 14 19 11 17 16 18 24 25 23 14 28 18 28 29 22 26 25 26 36 26 25 24 31 27 32 37 27 31 31 43 38 32 29 27 31 39 38 23 34 34 47 50 42 38 34 34 37 37 32 38 45 53 39 34 43 45 23 47 32 40 38 54 41 44 38 47 34 49 50 32 53 54 39 43 53 51 45 26 43 52 62 50 59 48 41 45 55 48 41 48 36 48 41 59 57 48 51 48 50 36 53 61 52 55 49 49 46 48 50 52 50 71 55 47 58 53 60 48 52 70 47 51 61 47 67 53 62 63 50 52 52 59 47 55 62 58 59 56 44 49 65 58 54 61 60 58 70 61 58 49 63 55 53 59 54 48 66 53 47 53 56 64 69 51 70 52 65 64 75 53 55 59 56 63 61 53 58 69 61 63 52 48 54 46 49 59 50 61 34 53 38 45 46 33 44 26 31 35 47 40 39 42 31 30 34 27 32 35 35 30 30 23 24 29 21 12 19 26 15 23 20 15 17 12 15 12 8 13 15 9 10 9 13 10 6 6 8 4 5 3 4 3 5 6 7 2 1 4 3 1 2 4 2 1 1 1 1 1 1];\r\nassert(isequal(a(1:100),a100_correct))\r\nassert(isequal(sum(a),sum_correct))\r\nassert(isequal(u,u_correct))\r\nassert(isequal(h,h_correct))\r\n\r\n%%\r\nfiletext = fileread('primeSquareCube.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'regexp'); \r\nassert(~illegal)","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":46909,"edited_by":46909,"edited_at":"2025-07-16T16:58:51.000Z","deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2024-03-16T13:48:17.000Z","updated_at":"2025-07-26T04:58:48.000Z","published_at":"2024-03-16T13:51:57.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:t\u003eWhile traveling on an interstate highway, I noticed a sign that gave distances to three places. The distances were 3, 8, and 9 miles, or a prime, a perfect cube, and a perfect square. I then wondered whether it was possible to express integers (above a certain value) as the sum of a prime, a square, and a cube. For example, 11 can be expressed as \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\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"2+1+8 = 2+1^2+2^3\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e2+1+8 = 2+1^2+2^3\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e, and 17 can be expressed as \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\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"5+4+8 = 5 + 2^2+2^3\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e5+4+8 = 5 + 2^2+2^3\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e or \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\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"7+9+1 = 7+3^2+1^3\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e7+9+1 = 7+3^2+1^3\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=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to list ways to express numbers as the sum of a prime, a square, and a cube. All three must be positive. The function should return a matrix the primes in the first column, the squares in the second, and the cubs in the third, and the rows should be sorted by the first column and then the second. Given an input of 11, the function should return [2 1 8], and given an input of 17, the function should return [5 4 8; 7 9 1]. If the input cannot be expressed in this way, return the empty vector \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[\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\u003eOptional: Prove that all integers greater than 6 can be expressed as the sum of a prime, a square, and a cube.\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":1873,"title":"Break it up!  Break it up!","description":"You have N pennies.  Write a Matlab script that will reveal how many different ways you can break up those pennies.  For example, with 5 pennies, there are seven different ways you can divide them:\r\n\r\n* (1,1,1,1,1)\r\n* (2,1,1,1)\r\n* (2,2,1)\r\n* (3,2)\r\n* (3,1,1)\r\n* (4,1)\r\n* (5)\r\n\r\nThe order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2).  You can assume that N will always be a positive integer.","description_html":"\u003cp\u003eYou have N pennies.  Write a Matlab script that will reveal how many different ways you can break up those pennies.  For example, with 5 pennies, there are seven different ways you can divide them:\u003c/p\u003e\u003cul\u003e\u003cli\u003e(1,1,1,1,1)\u003c/li\u003e\u003cli\u003e(2,1,1,1)\u003c/li\u003e\u003cli\u003e(2,2,1)\u003c/li\u003e\u003cli\u003e(3,2)\u003c/li\u003e\u003cli\u003e(3,1,1)\u003c/li\u003e\u003cli\u003e(4,1)\u003c/li\u003e\u003cli\u003e(5)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2).  You can assume that N will always be a positive integer.\u003c/p\u003e","function_template":"function y = partitions(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;y_correct = 1;assert(isequal(partitions(x),y_correct))\r\n%%\r\nx = 5;y_correct = 7;assert(isequal(partitions(x),y_correct))\r\n%%\r\nx = 50;y_correct = 204226;assert(isequal(partitions(x),y_correct))\r\n%%\r\nassert(isequal(partitions(partitions(partitions(partitions(5)))),476715857290));\r\n%%\r\nassert(isequal(partitions(partitions(partitions(6))),526823));\r\n%%\r\nassert(isequal(partitions(partitions(12)),10619863));\r\n%%\r\nassert(isequal(partitions(199),3646072432125))\r\n%%\r\nP=arrayfun(@(x) partitions(x),10:10:100);\r\ny_correct=[42 627 5604 37338 204226 966467 4087968 15796476 56634173 190569292];\r\nassert(all(isequal(P,y_correct)))","published":true,"deleted":false,"likes_count":4,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":81,"test_suite_updated_at":"2016-08-19T11:36:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-13T18:34:19.000Z","updated_at":"2026-04-03T20:00:35.000Z","published_at":"2013-09-13T18:34:19.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\u003eYou have N pennies. Write a Matlab script that will reveal how many different ways you can break up those pennies. For example, with 5 pennies, there are seven different ways you can divide them:\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\u003e(1,1,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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(2,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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(2,2,1)\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\u003e(3,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\u003e(3,1,1)\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\u003e(4,1)\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\u003e(5)\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 order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2). You can assume that N will always be a positive integer.\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:\"partitions\"","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:\"partitions\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"partitions\"","","\"","partitions","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f194b3d80e0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f194b3d8040\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f194b3d7780\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f194b3d8360\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f194b3d82c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f194b3d8220\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f194b3d8180\u003e":"tag:\"partitions\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f194b3d8180\u003e":"tag:\"partitions\""},"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":"search","password":"J3bGPZzQ7asjJcCk","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:\"partitions\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"partitions\"","","\"","partitions","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f194b3d80e0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f194b3d8040\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f194b3d7780\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f194b3d8360\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f194b3d82c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f194b3d8220\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f194b3d8180\u003e":"tag:\"partitions\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f194b3d8180\u003e":"tag:\"partitions\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":42918,"difficulty_rating":"easy-medium"},{"id":58359,"difficulty_rating":"medium"},{"id":59701,"difficulty_rating":"medium"},{"id":1873,"difficulty_rating":"medium-hard"}]}}