{"group":{"group":{"id":58,"name":"Magic Numbers IV","lockable":false,"created_at":"2020-04-27T20:19:23.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Not as easy as 1, 2, 3, but much more satisfying.","is_default":false,"created_by":26769,"badge_id":62,"featured":false,"trending":false,"solution_count_in_trending_period":28,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":652,"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":"{\"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\u003eNot as easy as 1, 2, 3, but much more satisfying.\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\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; 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: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 10.5px; transform-origin: 289.5px 10.5px; \"\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; white-space: pre-wrap; perspective-origin: 266.5px 10.5px; transform-origin: 266.5px 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; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eNot as easy as 1, 2, 3, but much more satisfying.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2020-04-27T20:18:29.000Z"},"current_player":null},"problems":[{"id":42377,"title":"Bouncy numbers","description":"Inspired by Project Euler n°112.\r\n\r\nWorking from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number. For example: 134468.\r\n\r\nSimilarly if no digit is exceeded by the digit to its right it is called a decreasing number. For example: 66420.\r\nWe shall call a positive integer that is neither increasing nor decreasing a bouncy number. For example, 155349.\r\nClearly there cannot be any bouncy numbers below one-hundred, but surprisingly, these numbers become more and more common after.\r\nFind the least number for which the proportion of bouncy numbers is exactly p%.\r\nAs always this type of problem is difficult to solve with usual Matlab functions (num2str).\r\nSo keep an eye on time...","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: 315.167px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 157.583px; transform-origin: 407px 157.583px; 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: 99.5px 8px; transform-origin: 99.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInspired by Project Euler n°112.\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: 391px 51.0833px; transform-origin: 391px 51.0833px; 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\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: 363px 20.4333px; text-align: left; transform-origin: 363px 20.4333px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 256.5px 8px; transform-origin: 256.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWorking from left-to-right if no digit is exceeded by the digit to its left it is called an\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 66px 8px; transform-origin: 66px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eincreasing number\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 17px 8px; transform-origin: 17px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. For example: 134468.\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\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: 204.5px 8px; transform-origin: 204.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSimilarly if no digit is exceeded by the digit to its right it is called a\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 39.5px 8px; transform-origin: 39.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003edecreasing\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 94.5px 8px; transform-origin: 94.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e number. For example: 66420.\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: 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: 230.5px 8px; transform-origin: 230.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWe shall call a positive integer that is neither increasing nor decreasing a\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\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-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.5px 8px; transform-origin: 25.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ebouncy\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: 98.5px 8px; transform-origin: 98.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e number. For example, 155349.\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: 368.5px 8px; transform-origin: 368.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eClearly there cannot be any bouncy numbers below one-hundred, but surprisingly, these numbers become more and more common after.\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: 252.5px 8px; transform-origin: 252.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFind the least number for which the proportion of bouncy numbers is exactly p%.\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: 273.5px 8px; transform-origin: 273.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAs always this type of problem is difficult to solve with usual Matlab functions (num2str).\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: 80.5px 8px; transform-origin: 80.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSo keep an eye on time...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = bouncy_numbers(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 0.01;\r\ny_correct = 102;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.05;\r\ny_correct = 106;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.1;\r\ny_correct = 132;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.2;\r\ny_correct = 175;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.5;\r\ny_correct = 538;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.8;\r\ny_correct = 4770;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.9;\r\ny_correct = 21780;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.95;\r\ny_correct = 63720;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.96;\r\ny_correct = 152975;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.97;\r\ny_correct = 208200;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.98;\r\ny_correct = 377650;\r\nassert(isequal(bouncy_numbers(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":45,"test_suite_updated_at":"2021-07-22T06:29:35.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-06-14T23:04:12.000Z","updated_at":"2026-03-16T15:11:37.000Z","published_at":"2015-06-14T23:09:36.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\u003eInspired by Project Euler n°112.\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\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\u003eWorking from left-to-right if no digit is exceeded by the digit to its left it is called an\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\u003eincreasing number\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. For example: 134468.\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\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\u003eSimilarly if no digit is exceeded by the digit to its right it is called 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\u003edecreasing\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e number. For example: 66420.\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\u003eWe shall call a positive integer that is neither increasing nor decreasing 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\u003ebouncy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e number. For example, 155349.\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\u003eClearly there cannot be any bouncy numbers below one-hundred, but surprisingly, these numbers become more and more common after.\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\u003eFind the least number for which the proportion of bouncy numbers is exactly p%.\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 always this type of problem is difficult to solve with usual Matlab functions (num2str).\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\u003eSo keep an eye on time...\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":42394,"title":"It's going down.  We're finding simbers!","description":"This problem is inspired by Project Euler 520: Simbers.\r\n\r\n\"We define a simber to be a positive integer in which any odd digit, if present, occurs an odd number of times, and any even digit, if present, occurs an even number of times.\r\n\r\nFor example, 141221242 is a 9-digit simber because it has three 1's, four 2's and two 4's.\"\r\n\r\nGiven a number, determine if it a simber or not.  Please note that the number will be in *string* format as some of the entries may be quite long.  You can assume there will be no leading zeroes in any of the numbers.\r\n","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: 332px 87px; vertical-align: baseline; perspective-origin: 332px 87px; \"\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=\"\"\u003eThis problem is inspired by Project Euler 520: Simbers.\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 21px; white-space: pre-wrap; perspective-origin: 309px 21px; 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=\"\"\u003e\"We define a simber to be a positive integer in which any odd digit, if present, occurs an odd number of times, and any even digit, if present, occurs an even number of times.\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, 141221242 is a 9-digit simber because it has three 1's, four 2's and two 4's.\"\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 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=\"\"\u003eGiven a number, determine if it a simber or not. Please note that the number will be in\u003c/span\u003e\u003c/span\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=\"\"\u003e \u003c/span\u003e\u003c/span\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=\"font-weight: bold; \"\u003estring\u003c/span\u003e\u003c/span\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=\"\"\u003e format as some of the entries may be quite long. You can assume there will be no leading zeroes in any of the numbers.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = simber(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(simber('141221242'),true))\r\n%%\r\nassert(isequal(simber('1223334444'),true))\r\n%%\r\nassert(isequal(simber('122333444'),false))\r\n%%\r\nassert(isequal(simber('567886'),true))\r\n%%\r\nassert(isequal(simber('999999999888888888'),false))\r\n%%\r\nassert(isequal(simber('6677788'),true))\r\n%%\r\nv=arrayfun(@(x) simber(num2str(x)),1:100);\r\ny_correct=[1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 1];\r\nassert(isequal(v,y_correct))\r\n%%\r\nk=arrayfun(@(x) simber(sprintf('%.0f',2^x+1)),1:39);\r\ny_correct=[1 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];\r\nassert(isequal(k,y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":87,"test_suite_updated_at":"2020-09-29T03:05:43.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-06-18T19:55:17.000Z","updated_at":"2026-03-16T15:14:55.000Z","published_at":"2015-06-18T19:55:17.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\u003eThis problem is inspired by Project Euler 520: Simbers.\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\\\"We define a simber to be a positive integer in which any odd digit, if present, occurs an odd number of times, and any even digit, if present, occurs an even number of times.\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, 141221242 is a 9-digit simber because it has three 1's, four 2's and two 4's.\\\"\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 number, determine if it a simber or not. Please note that the number will be in\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\u003estring\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e format as some of the entries may be quite long. You can assume there will be no leading zeroes in any of the numbers.\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":42826,"title":"Euler–Mascheroni constant","description":"Approximate the Euler-Mascheroni constant using the series representation \r\n\r\ngamma_n=\\sum_{k=1}^{n} [1/k-ln(1+1/k)]\r\n\r\nCalculate partial sum gamma_n for a given integer n!","description_html":"\u003cp\u003eApproximate the Euler-Mascheroni constant using the series representation\u003c/p\u003e\u003cp\u003egamma_n=\\sum_{k=1}^{n} [1/k-ln(1+1/k)]\u003c/p\u003e\u003cp\u003eCalculate partial sum gamma_n for a given integer n!\u003c/p\u003e","function_template":"function gamma = euler_mascheroni_constant(n)\r\ngamma=0;\r\nend","test_suite":"%%\r\nn = 1;\r\ngamma_n_correct = 0.3069;\r\nassert(abs(euler_mascheroni_constant(n)-gamma_n_correct)\u003c0.001);\r\n\r\n%%\r\nn = 2;\r\ngamma_n_correct = 0.4014;\r\nassert(abs(euler_mascheroni_constant(n)-gamma_n_correct)\u003c0.001);\r\n\r\n%%\r\nn = 3;\r\ngamma_n_correct = 0.4470;\r\nassert(abs(euler_mascheroni_constant(n)-gamma_n_correct)\u003c0.001);\r\n\r\n%%\r\nn = 10;\r\ngamma_n_correct = 0.5311;\r\nassert(abs(euler_mascheroni_constant(n)-gamma_n_correct)\u003c0.001);\r\n\r\n%%\r\nn = 100;\r\ngamma_n_correct = 0.5723;\r\nassert(abs(euler_mascheroni_constant(n)-gamma_n_correct)\u003c0.001);\r\n\r\n%%\r\nn = 1000;\r\ngamma_n_correct = 0.5767;\r\nassert(abs(euler_mascheroni_constant(n)-gamma_n_correct)\u003c0.001);","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":73322,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-04-24T18:36:16.000Z","updated_at":"2026-03-30T18:40:06.000Z","published_at":"2016-04-24T18:36:16.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\u003eApproximate the Euler-Mascheroni constant using the series representation\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\u003egamma_n=\\\\sum_{k=1}^{n} [1/k-ln(1+1/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\u003eCalculate partial sum gamma_n for a given integer 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":42830,"title":"Hilbert numbers","description":"Given a positive integer, n, return h as follows:\r\n\r\n1. If n is not a \u003chttps://en.wikipedia.org/wiki/Hilbert_number Hilbert number\u003e, return h = 0\r\n\r\n2. If n is a Hilbert prime, return h = 1\r\n\r\n3. If n is a Hilbert non-prime, return all of its Hilbert factors in one sorted vector. \r\n\r\nExample 1:\r\n\r\nn = 3\r\n\r\nh = 0\r\n\r\nExample 2:\r\n\r\nn = 5\r\n\r\nh = 1\r\n\r\nExample 3:\r\n\r\nn = 45\r\n\r\nh = [5 9]\r\n\r\nExample 4:\r\n\r\nn = 441\r\n\r\nh = [9 21 49]","description_html":"\u003cp\u003eGiven a positive integer, n, return h as follows:\u003c/p\u003e\u003cp\u003e1. If n is not a \u003ca href = \"https://en.wikipedia.org/wiki/Hilbert_number\"\u003eHilbert number\u003c/a\u003e, return h = 0\u003c/p\u003e\u003cp\u003e2. If n is a Hilbert prime, return h = 1\u003c/p\u003e\u003cp\u003e3. If n is a Hilbert non-prime, return all of its Hilbert factors in one sorted vector.\u003c/p\u003e\u003cp\u003eExample 1:\u003c/p\u003e\u003cp\u003en = 3\u003c/p\u003e\u003cp\u003eh = 0\u003c/p\u003e\u003cp\u003eExample 2:\u003c/p\u003e\u003cp\u003en = 5\u003c/p\u003e\u003cp\u003eh = 1\u003c/p\u003e\u003cp\u003eExample 3:\u003c/p\u003e\u003cp\u003en = 45\u003c/p\u003e\u003cp\u003eh = [5 9]\u003c/p\u003e\u003cp\u003eExample 4:\u003c/p\u003e\u003cp\u003en = 441\u003c/p\u003e\u003cp\u003eh = [9 21 49]\u003c/p\u003e","function_template":"function h = hilbertnum(n)\r\n  h = 0;\r\nend","test_suite":"%%\r\nn = 3;\r\nh_correct = 0;\r\nassert(isequal(hilbertnum(n),h_correct))\r\n\r\n%%\r\nn = 5;\r\nh_correct = 1;\r\nassert(isequal(hilbertnum(n),h_correct))\r\n\r\n%%\r\nn = 45;\r\nh_correct = [5 9];\r\nassert(isequal(hilbertnum(n),h_correct))\r\n\r\n%%\r\nn = 1169;\r\nh_correct = 1;\r\nassert(isequal(hilbertnum(n),h_correct))\r\n\r\n%%\r\nn = 441;\r\nh_correct = [9 21 49];\r\nassert(isequal(hilbertnum(n),h_correct))\r\n\r\n%%\r\nn = 45678;\r\nh_correct = 0;\r\nassert(isequal(hilbertnum(n),h_correct))\r\n\r\n%%\r\nn = 56789;\r\nh_correct = [109 521];\r\nassert(isequal(hilbertnum(n),h_correct))\r\n\r\n%%\r\nn = 353535;\r\nh_correct = 0;\r\nassert(isequal(hilbertnum(n),h_correct))\r\n\r\n%%\r\nn = 35353549;\r\nh_correct = [49 77 613 749 1177 30037 47201 57673 459137 721501];\r\nassert(isequal(hilbertnum(n),h_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":15521,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-04-25T18:22:53.000Z","updated_at":"2026-03-02T11:43:26.000Z","published_at":"2016-04-25T18:22:53.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\u003eGiven a positive integer, n, return h as follows:\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. If n is not 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=\\\"https://en.wikipedia.org/wiki/Hilbert_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eHilbert number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, return h = 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2. If n is a Hilbert prime, return h = 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\u003e3. If n is a Hilbert non-prime, return all of its Hilbert factors in one sorted vector.\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\u003eExample 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\u003en = 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eh = 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en = 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\u003eh = 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\u003eExample 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en = 45\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\u003eh = [5 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample 4:\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\u003en = 441\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\u003eh = [9 21 49]\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":42913,"title":"Pseudo Square Root (Inspired by Project Euler 266)","description":"Shamelessly copied from the Project Euler page for Problem 266:\r\n-------------\r\n\r\nThe divisors of 12 are: 1,2,3,4,6 and 12.\r\n\r\nThe largest divisor of 12 that does not exceed the square root of 12 is 3.\r\n\r\nWe shall call the largest divisor of an integer n that does not exceed the square root of n the pseudo square root (PSR) of n.\r\n\r\nIt can be seen that PSR(3102)=47.\r\n\r\n-------------\r\n\r\nWrite a MATLAB script that will determine what the pseudo square root of a number is.  Please note that if the number is a perfect square, the pseudo square root will equal the actual square root.","description_html":"\u003cp\u003eShamelessly copied from the Project Euler page for Problem 266:\r\n-------------\u003c/p\u003e\u003cp\u003eThe divisors of 12 are: 1,2,3,4,6 and 12.\u003c/p\u003e\u003cp\u003eThe largest divisor of 12 that does not exceed the square root of 12 is 3.\u003c/p\u003e\u003cp\u003eWe shall call the largest divisor of an integer n that does not exceed the square root of n the pseudo square root (PSR) of n.\u003c/p\u003e\u003cp\u003eIt can be seen that PSR(3102)=47.\u003c/p\u003e\u003cp\u003e-------------\u003c/p\u003e\u003cp\u003eWrite a MATLAB script that will determine what the pseudo square root of a number is.  Please note that if the number is a perfect square, the pseudo square root will equal the actual square root.\u003c/p\u003e","function_template":"function y = PSR(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 12;y_correct = 3;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\nx = 3102;y_correct = 47;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\nx=10000;y_correct = 100;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\nx=1308276133167003;y_correct = 36105377;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\nx=6469693230;y_correct = 79534;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\np=cumprod(1:10);\r\ny=arrayfun(@(p) PSR(p),p);\r\ny_correct=[1 1 2 4 10 24 70 192 576 1890];\r\nassert(isequal(y,y_correct))\r\n%%\r\nx=1000000000000002;\r\nassert(isequal(PSR(PSR(x)),2))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":60,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-07-19T13:50:36.000Z","updated_at":"2026-03-16T15:35:55.000Z","published_at":"2016-07-19T13:50:36.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\u003eShamelessly copied from the Project Euler page for Problem 266: -------------\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 divisors of 12 are: 1,2,3,4,6 and 12.\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 largest divisor of 12 that does not exceed the square root of 12 is 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\u003eWe shall call the largest divisor of an integer n that does not exceed the square root of n the pseudo square root (PSR) of 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIt can be seen that PSR(3102)=47.\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\u003eWrite a MATLAB script that will determine what the pseudo square root of a number is. Please note that if the number is a perfect square, the pseudo square root will equal the actual square root.\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":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":42917,"title":"Nth roots of unity","description":"First, find the n nth roots of unity.\r\neg if n = 6, find the n distinct (complex) numbers such that n^6 = 1.\r\n\r\n\u003chttps://en.wikipedia.org/wiki/Root_of_unity\u003e\r\n\r\nSecond, raise each root to the power pi (.^pi).\r\n\r\nThird, sum the resulting numbers and use that as the output. \r\n","description_html":"\u003cp\u003eFirst, find the n nth roots of unity.\r\neg if n = 6, find the n distinct (complex) numbers such that n^6 = 1.\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://en.wikipedia.org/wiki/Root_of_unity\"\u003ehttps://en.wikipedia.org/wiki/Root_of_unity\u003c/a\u003e\u003c/p\u003e\u003cp\u003eSecond, raise each root to the power pi (.^pi).\u003c/p\u003e\u003cp\u003eThird, sum the resulting numbers and use that as the output.\u003c/p\u003e","function_template":"function y = your_fcn_name(n)\r\n  y = 0;\r\nend","test_suite":"%%\r\nn = 5;\r\ny_correct =  -0.467800202134647;\r\nassert( abs(your_fcn_name(n)-y_correct) \u003c .0001)\r\n\r\n%%\r\nn = 50;\r\ny_correct = -2.151544927902936 - 0.430301217000093i\r\nassert( abs(your_fcn_name(n)-y_correct) \u003c .0001)\r\n\r\n%%\r\nn = 7;\r\ny_correct =   -0.435928596902380\r\nassert( abs(your_fcn_name(n)-y_correct) \u003c .0001)\r\n\r\n\r\n%%\r\nn = 70;\r\ny_correct =   -3.031653804728051 - 0.430301217000095i\r\nassert( abs(your_fcn_name(n)-y_correct) \u003c .0001)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":65480,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":67,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-08-01T00:25:42.000Z","updated_at":"2026-02-24T14:03:00.000Z","published_at":"2016-08-01T00:25:42.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\u003eFirst, find the n nth roots of unity. eg if n = 6, find the n distinct (complex) numbers such that n^6 = 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:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Root_of_unity\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Root_of_unity\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\u003eSecond, raise each root to the power pi (.^pi).\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\u003eThird, sum the resulting numbers and use that as the output.\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":43584,"title":"Find Pseudo-Cyclic Number","description":"A cyclic number is an integer in which cyclic permutations of the digits are successive multiples of the number https://en.wikipedia.org/wiki/Cyclic_number\u003e). The most widely known is 142857:\r\n\r\n\r\n    142857 × 1 = 142857\r\n    142857 × 2 = 285714\r\n    142857 × 3 = 428571\r\n    142857 × 4 = 571428\r\n    142857 × 5 = 714285\r\n    142857 × 6 = 857142 \r\n\r\n\r\nIn fact, 142857 is the only cyclic number in decimal, if leading zeros are not permitted on numerals.\r\n\r\nTherefore, instead of the pure cyclic number, we will find the integer in which *any* cyclic permutations of the digits are *any* multiples of the number.\r\n\r\nFor example, 230769 is the one, because 23076 *9* x 4 = *9* 23076.\r\n\r\n\r\n\r\nGiven an integer x, return whether x is a pesudo-cyclic number.\r\n\r\n","description_html":"\u003cp\u003eA cyclic number is an integer in which cyclic permutations of the digits are successive multiples of the number https://en.wikipedia.org/wiki/Cyclic_number\u0026gt;). The most widely known is 142857:\u003c/p\u003e\u003cpre\u003e    142857 × 1 = 142857\r\n    142857 × 2 = 285714\r\n    142857 × 3 = 428571\r\n    142857 × 4 = 571428\r\n    142857 × 5 = 714285\r\n    142857 × 6 = 857142 \u003c/pre\u003e\u003cp\u003eIn fact, 142857 is the only cyclic number in decimal, if leading zeros are not permitted on numerals.\u003c/p\u003e\u003cp\u003eTherefore, instead of the pure cyclic number, we will find the integer in which \u003cb\u003eany\u003c/b\u003e cyclic permutations of the digits are \u003cb\u003eany\u003c/b\u003e multiples of the number.\u003c/p\u003e\u003cp\u003eFor example, 230769 is the one, because 23076 \u003cb\u003e9\u003c/b\u003e x 4 = \u003cb\u003e9\u003c/b\u003e 23076.\u003c/p\u003e\u003cp\u003eGiven an integer x, return whether x is a pesudo-cyclic number.\u003c/p\u003e","function_template":"function y = cyclicNumber(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = false;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 230769;\r\ny_correct = true;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 307692;\r\ny_correct = true;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 307691;\r\ny_correct = false;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 307693;\r\ny_correct = false;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = false;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 285714;\r\ny_correct = true;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 55;\r\ny_correct = false;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 142857142857;\r\ny_correct = true;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n%%\r\nx = 142857;\r\ny_correct = true;\r\nassert(isequal(cyclicNumber(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":1,"created_by":83468,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":39,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-21T09:35:07.000Z","updated_at":"2026-03-18T16:13:12.000Z","published_at":"2016-10-21T09:35:23.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\u003eA cyclic number is an integer in which cyclic permutations of the digits are successive multiples of the number\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://en.wikipedia.org/wiki/Cyclic_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttps://en.wikipedia.org/wiki/Cyclic_number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;). The most widely known is 142857:\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[    142857 × 1 = 142857\\n    142857 × 2 = 285714\\n    142857 × 3 = 428571\\n    142857 × 4 = 571428\\n    142857 × 5 = 714285\\n    142857 × 6 = 857142]]\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\u003eIn fact, 142857 is the only cyclic number in decimal, if leading zeros are not permitted on numerals.\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\u003eTherefore, instead of the pure cyclic number, we will find the integer in which\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\u003eany\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e cyclic permutations of the digits are\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\u003eany\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e multiples of the 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:r\u003e\u003cw:t\u003eFor example, 230769 is the one, because 23076\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\u003e9\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x 4 =\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\u003e9\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 23076.\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\u003eGiven an integer x, return whether x is a pesudo-cyclic number.\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":43754,"title":"Lah Numbers","description":"Create a square lower diagonal matrix containing the first n Lah number coefficients. In mathematics, the Lah numbers are coefficients expressing rising factorials in terms of falling factorials. For example, for n=8, the matrix of Lah numbers would be:\r\n\r\n  1\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\r\n2\t1\t0\t0\t0\t0\t0\t0\t0\t0\t0\r\n6\t6\t1\t0\t0\t0\t0\t0\t0\t0\t0\r\n24\t36\t12\t1\t0\t0\t0\t0\t0\t0\t0\r\n120\t240\t120\t20\t1\t0\t0\t0\t0\t0\t0\r\n720\t1800\t1200\t300\t30\t1\t0\t0\t0\t0\t0\r\n5040\t15120\t12600\t4200\t630\t42\t1\t0\t0\t0\t0\r\n40320\t141120\t141120\t58800\t11760\t1176\t56\t1\t0\t0\t0\r\n362880\t1451520\t1693440\t846720\t211680\t28224\t2016\t72\t1\t0\t0\r\n\r\nSee \u003chttps://en.wikipedia.org/wiki/Lah_number Lah Number\u003e for more information.","description_html":"\u003cp\u003eCreate a square lower diagonal matrix containing the first n Lah number coefficients. In mathematics, the Lah numbers are coefficients expressing rising factorials in terms of falling factorials. For example, for n=8, the matrix of Lah numbers would be:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\r\n2\t1\t0\t0\t0\t0\t0\t0\t0\t0\t0\r\n6\t6\t1\t0\t0\t0\t0\t0\t0\t0\t0\r\n24\t36\t12\t1\t0\t0\t0\t0\t0\t0\t0\r\n120\t240\t120\t20\t1\t0\t0\t0\t0\t0\t0\r\n720\t1800\t1200\t300\t30\t1\t0\t0\t0\t0\t0\r\n5040\t15120\t12600\t4200\t630\t42\t1\t0\t0\t0\t0\r\n40320\t141120\t141120\t58800\t11760\t1176\t56\t1\t0\t0\t0\r\n362880\t1451520\t1693440\t846720\t211680\t28224\t2016\t72\t1\t0\t0\r\n\u003c/pre\u003e\u003cp\u003eSee \u003ca href = \"https://en.wikipedia.org/wiki/Lah_number\"\u003eLah Number\u003c/a\u003e for more information.\u003c/p\u003e","function_template":"function y = lah(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 8;\r\ny_correct = [1,0,0,0,0,0,0,0,0;2,1,0,0,0,0,0,0,0;6,6,1,0,0,0,0,0,0;24,36,12,1,0,0,0,0,0;120,240,120,20,1,0,0,0,0;720,1800,1200,300,30,1,0,0,0;5040,15120,12600,4200,630,42,1,0,0;40320,141120,141120,58800,11760,1176,56,1,0;362880,1451520,1693440,846720,211680,28224,2016,72,1];\r\nassert(isequal(lah(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = [1,0;2,1];\r\nassert(isequal(lah(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = [1,0,0,0;2,1,0,0;6,6,1,0;24,36,12,1];\r\nassert(isequal(lah(x),y_correct))\r\n%%\r\nx = 10;\r\ny_correct = [1,0,0,0,0,0,0,0,0,0,0;2,1,0,0,0,0,0,0,0,0,0;6,6,1,0,0,0,0,0,0,0,0;24,36,12,1,0,0,0,0,0,0,0;120,240,120,20,1,0,0,0,0,0,0;720,1800,1200,300,30,1,0,0,0,0,0;5040,15120,12600,4200,630,42,1,0,0,0,0;40320,141120,141120,58800,11760,1176,56,1,0,0,0;362880,1451520,1693440,846720,211680,28224,2016,72,1,0,0;3628800,16329600,21772800,12700800,3810240,635040,60480,3240,90,1,0;39916800,199584000,299376000,199584000,69854400,13970880,1663200,118800,4950,110,1];\r\nassert(isequal(lah(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":93456,"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":"2016-12-07T22:42:33.000Z","updated_at":"2026-03-16T15:18:40.000Z","published_at":"2016-12-07T22:42:33.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\u003eCreate a square lower diagonal matrix containing the first n Lah number coefficients. In mathematics, the Lah numbers are coefficients expressing rising factorials in terms of falling factorials. For example, for n=8, the matrix of Lah numbers would be:\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  0  0  0  0  0  0  0  0  0  0\\n2  1  0  0  0  0  0  0  0  0  0\\n6  6  1  0  0  0  0  0  0  0  0\\n24  36  12  1  0  0  0  0  0  0  0\\n120  240  120  20  1  0  0  0  0  0  0\\n720  1800  1200  300  30  1  0  0  0  0  0\\n5040  15120  12600  4200  630  42  1  0  0  0  0\\n40320  141120  141120  58800  11760  1176  56  1  0  0  0\\n362880  1451520  1693440  846720  211680  28224  2016  72  1  0  0]]\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\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=\\\"https://en.wikipedia.org/wiki/Lah_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eLah Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for more information.\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":44062,"title":"Polar Form Complex Number Entry","description":"Write a function that takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction.  Must return NaN if mag is negative.","description_html":"\u003cp\u003eWrite a function that takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction.  Must return NaN if mag is negative.\u003c/p\u003e","function_template":"function c = cp2r(mag,arg_deg)\r\n  c = ;\r\nend","test_suite":"%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 1;\r\narg_deg=0;\r\nc_correct = 1;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 1;\r\narg_deg=90;\r\nc_correct = i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 5;\r\narg_deg=-30;\r\nc_correct = 4.33012701892219e+00 - 2.50000000000000e+00i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = -2;\r\narg_deg=-20;\r\nassert(isnan(cp2r(mag,arg_deg)))\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 0.1;\r\narg_deg=-8000;\r\nc_correct = 17.36481776669513e-03 -  98.48077530122045e-03i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":114158,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":"2017-02-09T18:33:39.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-08T16:21:38.000Z","updated_at":"2026-02-19T10:05:51.000Z","published_at":"2017-02-08T16:21:38.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 takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction. Must return NaN if mag is negative.\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":1308,"title":"Give me Hamming on five, hold the mayo","description":"A Hamming Number is a positive number that has no prime factor greater than 5.  Given a number X, determine how many Hamming numbers are less than or equal to that number.  Please note that 1 counts as a Hamming number.\r\n\r\nScore will be based on the amount of time it takes your code to solve the test suite.","description_html":"\u003cp\u003eA Hamming Number is a positive number that has no prime factor greater than 5.  Given a number X, determine how many Hamming numbers are less than or equal to that number.  Please note that 1 counts as a Hamming number.\u003c/p\u003e\u003cp\u003eScore will be based on the amount of time it takes your code to solve the test suite.\u003c/p\u003e","function_template":"function y = hamming1(x)\r\n  y = 5;\r\nend","test_suite":"feval(@assignin,'caller','score',5000); % msec\r\nforbidden = '(feval|eval|regexp|inline|tic|assert)';\r\nassert(isempty(regexp(evalc('type hamming1'),forbidden)));\r\n%%\r\ntic\r\n%%\r\nx = 5; y_correct = 5; assert(isequal(hamming1(x),y_correct))\r\n%%\r\nx = 100; y_correct = 34; assert(isequal(hamming1(x),y_correct))\r\n%%\r\nx = 123456; y_correct = 327; assert(isequal(hamming1(x),y_correct))\r\n%%\r\nx = 10^13; y_correct = 4301; assert(isequal(hamming1(x),y_correct))\r\n%%\r\nx=1:20; y=arrayfun(@(z) hamming1(z),2.^x);\r\ny_correct=[2 4 7 12 19 27 38 52 68 87 110 137 167 201 240 284 332 386 446 511];\r\nassert(isequal(y,y_correct));\r\ntval=1000*toc\r\nfeval(  @assignin,'caller','score',floor(min(5000,tval ))  );","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2014-02-28T20:31:24.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-02-28T20:44:01.000Z","updated_at":"2026-03-16T15:27:12.000Z","published_at":"2013-02-28T20:44:01.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 Hamming Number is a positive number that has no prime factor greater than 5. Given a number X, determine how many Hamming numbers are less than or equal to that number. Please note that 1 counts as a Hamming 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eScore will be based on the amount of time it takes your code to solve the test suite.\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":44159,"title":"calculate PI without using pi function","description":"There are many methods to get the pi(Ratio of circumference to diameter). \r\nYou should get pi without using the pi function in MATLAB.\r\n\r\n\u003chttps://en.wikipedia.org/wiki/Pi\u003e The Chinese mathematician Zu Chongzhi, around 480 AD, calculated that π ≈ 355/113. With a correct value for its seven first decimal digits, this value of 3. 141592920 , remained the most accurate approximation of π available for the next 800 years.","description_html":"\u003cp\u003eThere are many methods to get the pi(Ratio of circumference to diameter). \r\nYou should get pi without using the pi function in MATLAB.\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://en.wikipedia.org/wiki/Pi\"\u003ehttps://en.wikipedia.org/wiki/Pi\u003c/a\u003e The Chinese mathematician Zu Chongzhi, around 480 AD, calculated that π ≈ 355/113. With a correct value for its seven first decimal digits, this value of 3. 141592920 , remained the most accurate approximation of π available for the next 800 years.\u003c/p\u003e","function_template":"function PAI = calculate_PAI\r\n  PAI = ...;\r\nend","test_suite":"%%\r\nassert(abs(calculate_PAI-pi)\u003c1e-7);\r\n%%\r\nfiletext = fileread('calculate_PAI.m');\r\nassert(isempty(strfind(filetext, 'pi')),'pi forbidden');\r\nassert(isempty(strfind(filetext, '3.14159')),'3.14159 forbidden');\r\nassert(isempty(strfind(filetext, 'str')),'str function forbidden');","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":125749,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":108,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-05-14T04:46:10.000Z","updated_at":"2026-04-03T02:56:43.000Z","published_at":"2017-05-14T04:46:10.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\u003eThere are many methods to get the pi(Ratio of circumference to diameter). You should get pi without using the pi function in MATLAB.\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://en.wikipedia.org/wiki/Pi\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Pi\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt; The Chinese mathematician Zu Chongzhi, around 480 AD, calculated that π ≈ 355/113. With a correct value for its seven first decimal digits, this value of 3. 141592920 , remained the most accurate approximation of π available for the next 800 years.\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":44229,"title":"How brilliant are you?","description":"A Brilliant number is defined as a number with two prime factors, both of which have the same number of digits.  Some examples:\r\n\r\n10=2*5.  Since 2 and 5 have the same number of digits, 10 is a brilliant number.\r\n\r\n22=2*11.  Although there are two prime factors, they have a different number of digits, so 22 is not a brilliant number.\r\n\r\n30=2*3*5.  Although each prime factor has the same number of digits, there are more than two of them, so 30 is not a brilliant number.\r\n\r\nGiven a number, write a MATLAB script to determine if the number is brilliant or not.","description_html":"\u003cp\u003eA Brilliant number is defined as a number with two prime factors, both of which have the same number of digits.  Some examples:\u003c/p\u003e\u003cp\u003e10=2*5.  Since 2 and 5 have the same number of digits, 10 is a brilliant number.\u003c/p\u003e\u003cp\u003e22=2*11.  Although there are two prime factors, they have a different number of digits, so 22 is not a brilliant number.\u003c/p\u003e\u003cp\u003e30=2*3*5.  Although each prime factor has the same number of digits, there are more than two of them, so 30 is not a brilliant number.\u003c/p\u003e\u003cp\u003eGiven a number, write a MATLAB script to determine if the number is brilliant or not.\u003c/p\u003e","function_template":"function y = brilliant(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(brilliant(4),1))\r\n%%\r\nassert(isequal(brilliant(8),0))\r\n%%\r\nassert(isequal(brilliant(40),0))\r\n%%\r\nassert(isequal(brilliant(343),0))\r\n%%\r\nassert(isequal(brilliant(1536),0))\r\n%%\r\nassert(isequal(brilliant(1537),1))\r\n%%\r\nassert(isequal(brilliant(49165),0))\r\n%%\r\nassert(isequal(brilliant(657721),1))\r\n%%\r\nassert(isequal(brilliant(768819),0))\r\n%%\r\nassert(isequal(brilliant(13717421),1))\r\n%%\r\nassert(isequal(brilliant(123456789),0))\r\n%%\r\nassert(isequal(brilliant(669562601),1))\r\n%%\r\nassert(isequal(brilliant(1234567890),0))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-06-01T18:34:04.000Z","updated_at":"2026-02-24T14:03:59.000Z","published_at":"2017-06-01T18:34:04.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 Brilliant number is defined as a number with two prime factors, both of which have the same number of digits. Some examples:\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\u003e10=2*5. Since 2 and 5 have the same number of digits, 10 is a brilliant 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e22=2*11. Although there are two prime factors, they have a different number of digits, so 22 is not a brilliant 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e30=2*3*5. Although each prime factor has the same number of digits, there are more than two of them, so 30 is not a brilliant 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a number, write a MATLAB script to determine if the number is brilliant or not.\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":44230,"title":"I'm going to enjoy watching you calculate, Mr Anderson","description":"Smith numbers are numbers such that if you add up all of the digits in the number, that sum equals the sum of all of the digits in all of their factors. This term was coined by Albert Wilansky, when he noticed the defining property in the phone number of his brother-in-law Harold Smith: 493-7775.\r\n4+9+3+7+7+7+5=42\r\nThe prime factors of 4937775 are 3, 5, 5, and 65837. 3+5+5+(6+5+8+3+7) = 42\r\nSince all prime numbers obviously meet this criteria, Smith numbers are defined as composite numbers. Write a MATLAB function that will tell you if a given number is a Smith number.","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: 174px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 87px; transform-origin: 407px 87px; 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: 375.5px 8px; transform-origin: 375.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSmith numbers are numbers such that if you add up all of the digits in the number, that sum equals the sum of all of the digits in all of their factors. This term was coined by Albert Wilansky, when he noticed the defining property in the phone number of his brother-in-law Harold Smith: 493-7775.\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: 64px 8px; transform-origin: 64px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e4+9+3+7+7+7+5=42\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: 251px 8px; transform-origin: 251px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe prime factors of 4937775 are 3, 5, 5, and 65837. 3+5+5+(6+5+8+3+7) = 42\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: 380.5px 8px; transform-origin: 380.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSince all prime numbers obviously meet this criteria, Smith numbers are defined as composite numbers. Write a MATLAB function that will tell you if a given number is a Smith number.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = smith(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(smith(4937775),1))\r\n%%\r\nassert(isequal(smith(1164),0))\r\n%%\r\nassert(isequal(smith(19683),1))\r\n%%\r\nassert(isequal(smith(11),0))  % Remember - Smith numbers are composite\r\n%%\r\nassert(isequal(smith(11^2),1))\r\n%%\r\nassert(isequal(smith(345741),1))\r\n%%\r\nassert(isequal(smith(19876),0))\r\n%%\r\nassert(isequal(smith(314159),0))\r\n%%\r\nassert(isequal(smith(612985),1))\r\n%%\r\nassert(isequal(smith(12379887),1))\r\n%%\r\nassert(isequal(smith(23456789),0))\r\n%%\r\nassert(isequal(smith(13),0))\r\n%%\r\nassert(isequal(smith(23),0))\r\n%%\r\ny=primes(randi(1e5));\r\nassert(isequal(smith(y(end)),0))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":1615,"edited_by":223089,"edited_at":"2023-01-07T08:26:27.000Z","deleted_by":null,"deleted_at":null,"solvers_count":49,"test_suite_updated_at":"2023-01-07T08:26:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-06-01T19:16:25.000Z","updated_at":"2026-03-16T15:29:16.000Z","published_at":"2017-06-01T19:16: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:t\u003eSmith numbers are numbers such that if you add up all of the digits in the number, that sum equals the sum of all of the digits in all of their factors. This term was coined by Albert Wilansky, when he noticed the defining property in the phone number of his brother-in-law Harold Smith: 493-7775.\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+9+3+7+7+7+5=42\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 prime factors of 4937775 are 3, 5, 5, and 65837. 3+5+5+(6+5+8+3+7) = 42\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\u003eSince all prime numbers obviously meet this criteria, Smith numbers are defined as composite numbers. Write a MATLAB function that will tell you if a given number is a Smith number.\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":44289,"title":"Find two triangular numbers whose sum is input.","description":"Find two triangular numbers whose sum is _input_.\r\n\r\nNote: The difference beetween the triangular numbers should be minimum.","description_html":"\u003cp\u003eFind two triangular numbers whose sum is \u003ci\u003einput\u003c/i\u003e.\u003c/p\u003e\u003cp\u003eNote: The difference beetween the triangular numbers should be minimum.\u003c/p\u003e","function_template":"function y = twoTriangular(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 400;\r\ny_correct = [190 210];\r\nassert(isequal(twoTriangular(x),y_correct))\r\n\r\n%%\r\nx = 196;\r\ny_correct = [91 105];\r\nassert(isequal(twoTriangular(x),y_correct))\r\n\r\n\r\n%%\r\nx = 676;\r\ny_correct = [325 351];\r\nassert(isequal(twoTriangular(x),y_correct))\r\n\r\n\r\n%%\r\nx = 1225;\r\ny_correct = [595 630];\r\nassert(isequal(twoTriangular(x),y_correct))\r\n\r\n\r\n%%\r\nx = 1849;\r\ny_correct = [903 946];\r\nassert(isequal(twoTriangular(x),y_correct))\r\n\r\n\r\n%%\r\nx = 10000;\r\ny_correct = [4950 5050];\r\nassert(isequal(twoTriangular(x),y_correct))\r\n\r\n\r\n\r\n%%\r\nx = 11025;\r\ny_correct = [5460 5565];\r\nassert(isequal(twoTriangular(x),y_correct))\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":103,"test_suite_updated_at":"2017-08-28T11:47:21.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-08-26T06:22:16.000Z","updated_at":"2026-03-16T15:31:26.000Z","published_at":"2017-08-26T06:22:16.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 two triangular numbers whose sum is\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003einput\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote: The difference beetween the triangular numbers should be minimum.\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":2027,"title":"Consecutive Powers","description":"Return 2 numbers and 2 powers such that their difference is 1\r\n\r\nA 4 element row vector is expected: x where \r\n\r\n x(1)^x(2) - x(3)^x(4) = 1;\r\n","description_html":"\u003cp\u003eReturn 2 numbers and 2 powers such that their difference is 1\u003c/p\u003e\u003cp\u003eA 4 element row vector is expected: x where\u003c/p\u003e\u003cpre\u003e x(1)^x(2) - x(3)^x(4) = 1;\u003c/pre\u003e","function_template":"function [x,y,p1,p2] = conpow()\r\n% your code here\r\nend","test_suite":"%%\r\nx=conpow();\r\nd = x(1)^x(2)-x(3)^x(4);\r\ny_correct = 1;\r\nassert(isequal(d,y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":17471,"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":1,"created_at":"2013-11-30T12:48:23.000Z","updated_at":"2026-02-25T10:57:25.000Z","published_at":"2013-11-30T12:57: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\u003eReturn 2 numbers and 2 powers such that their difference is 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\u003eA 4 element row vector is expected: x where\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)^x(2) - x(3)^x(4) = 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":44403,"title":"Goldbach's marginal conjecture - Write integer as sum of three primes","description":"Goldbach's strong conjecture states that every even integer greater than 2 can be expressed as the sum of two primes. For example: 4 = 2+2, 6 = 3+3, 8 = 3+5, 10 = 3+7 = 5+5, 12 = 5+7 etc.\r\n\r\nAs a corrollary, Goldbach's weak conjecture states that every odd integer greater than 7 can be expressed as the sum of three odd primes. For example: 9 = 3+3+3, 11 = 3+3+5, 13 = 3+3+7 = 3+5+5, 15 = 3+5+7 = 5+5+5 etc.\r\n\r\nA third conjecture was written by Goldbach in the margin of a letter, and (in its modern version) states that \r\n\r\n\" _Every integer greater than 5 can be expressed as the sum of three primes._ \"\r\n\r\nExamples:\r\n\r\n*  6 = 2 + 2 + 2\r\n*  7 = 2 + 2 + 3\r\n*  8 = 2 + 3 + 3 \r\n*  9 = 2 + 2 + 5 = 3 + 3 + 3 \r\n* 10 = 2 + 3 + 5\r\n* 11 = 2 + 2 + 7 = 3 + 3 + 5\r\n* 12 = 2 + 3 + 7 = 2 + 5 + 5\r\n* 13 = 3 + 3 + 7 = 3 + 5 + 5\r\n* 14 = 2 + 5 + 7\r\n* 15 = 2 + 2 + 11 = 3 + 5 + 7 = 5 + 5 + 5\r\n\r\nYour task is to write a function which takes a positive integer _n_ as input, and which returns a 1-by-3 vector _y_, which contains three numbers that are primes and whose sum equals _n_. If there exist multiple solutions for _y_, then any one of those solutions will suffice. However, _y_ must be in sorted order. You can assume that _n_ will be an integer greater than 5.\r\n\r\n","description_html":"\u003cp\u003eGoldbach's strong conjecture states that every even integer greater than 2 can be expressed as the sum of two primes. For example: 4 = 2+2, 6 = 3+3, 8 = 3+5, 10 = 3+7 = 5+5, 12 = 5+7 etc.\u003c/p\u003e\u003cp\u003eAs a corrollary, Goldbach's weak conjecture states that every odd integer greater than 7 can be expressed as the sum of three odd primes. For example: 9 = 3+3+3, 11 = 3+3+5, 13 = 3+3+7 = 3+5+5, 15 = 3+5+7 = 5+5+5 etc.\u003c/p\u003e\u003cp\u003eA third conjecture was written by Goldbach in the margin of a letter, and (in its modern version) states that\u003c/p\u003e\u003cp\u003e\" \u003ci\u003eEvery integer greater than 5 can be expressed as the sum of three primes.\u003c/i\u003e \"\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cul\u003e\u003cli\u003e6 = 2 + 2 + 2\u003c/li\u003e\u003cli\u003e7 = 2 + 2 + 3\u003c/li\u003e\u003cli\u003e8 = 2 + 3 + 3\u003c/li\u003e\u003cli\u003e9 = 2 + 2 + 5 = 3 + 3 + 3\u003c/li\u003e\u003cli\u003e10 = 2 + 3 + 5\u003c/li\u003e\u003cli\u003e11 = 2 + 2 + 7 = 3 + 3 + 5\u003c/li\u003e\u003cli\u003e12 = 2 + 3 + 7 = 2 + 5 + 5\u003c/li\u003e\u003cli\u003e13 = 3 + 3 + 7 = 3 + 5 + 5\u003c/li\u003e\u003cli\u003e14 = 2 + 5 + 7\u003c/li\u003e\u003cli\u003e15 = 2 + 2 + 11 = 3 + 5 + 7 = 5 + 5 + 5\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYour task is to write a function which takes a positive integer \u003ci\u003en\u003c/i\u003e as input, and which returns a 1-by-3 vector \u003ci\u003ey\u003c/i\u003e, which contains three numbers that are primes and whose sum equals \u003ci\u003en\u003c/i\u003e. If there exist multiple solutions for \u003ci\u003ey\u003c/i\u003e, then any one of those solutions will suffice. However, \u003ci\u003ey\u003c/i\u003e must be in sorted order. You can assume that \u003ci\u003en\u003c/i\u003e will be an integer greater than 5.\u003c/p\u003e","function_template":"function y = goldbach3(n)\r\n  y = [n,n,n];\r\nend","test_suite":"%%\r\nn = 6;\r\ny = goldbach3(n);\r\ny_correct = [2,2,2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 7;\r\ny = goldbach3(n);\r\ny_correct = [2,2,3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 8;\r\ny = goldbach3(n);\r\ny_correct = [2,3,3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 9;\r\ny = goldbach3(n);\r\ny_correct1 = [2,2,5];\r\ny_correct2 = [3,3,3];\r\nassert(isequal(y,y_correct1)|isequal(y,y_correct2))\r\n\r\n%%\r\nn = 10;\r\ny = goldbach3(n);\r\ny_correct = [2,3,5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 11;\r\ny = goldbach3(n);\r\ny_correct1 = [2,2,7];\r\ny_correct2 = [3,3,5];\r\nassert(isequal(y,y_correct1)|isequal(y,y_correct2))\r\n\r\n%%\r\nn = 12;\r\ny = goldbach3(n);\r\ny_correct1 = [2,3,7];\r\ny_correct2 = [2,5,5];\r\nassert(isequal(y,y_correct1)|isequal(y,y_correct2))\r\n\r\n%%\r\nn = 13;\r\ny = goldbach3(n);\r\ny_correct1 = [3,3,7];\r\ny_correct2 = [3,5,5];\r\nassert(isequal(y,y_correct1)|isequal(y,y_correct2))\r\n\r\n%%\r\nn = 14;\r\ny = goldbach3(n);\r\ny_correct = [2,5,7];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 15;\r\ny = goldbach3(n);\r\ny_correct1 = [2,2,11];\r\ny_correct2 = [3,5,7];\r\ny_correct3 = [5,5,5];\r\nassert(isequal(y,y_correct1)|isequal(y,y_correct2)|isequal(y,y_correct3))\r\n\r\n%%\r\nn = 101;\r\ny = goldbach3(n);\r\nassert(isequal(y,sort(y)))\r\nassert(all(isprime(y)))\r\nassert(sum(y)==n)\r\n\r\n%%\r\nn = 102;\r\ny = goldbach3(n);\r\nassert(isequal(y,sort(y)))\r\nassert(all(isprime(y)))\r\nassert(sum(y)==n)\r\n\r\n%% \r\nfor n = 250:300\r\n    y = goldbach3(n);\r\n    assert(isequal(y,sort(y)));\r\n    assert(all(isprime(y)));\r\n    assert(sum(y)==n);\r\nend\r\n\r\n%%\r\nn = randi(2000)+5; % generate a random integer greater than 5 and smaller than 2006\r\ny = goldbach3(n);\r\nassert(isequal(y,sort(y)))\r\nassert(all(isprime(y)))\r\nassert(sum(y)==n)\r\n\r\n%% \r\nvalid = zeros(1,50);\r\nfor k = 1:50\r\n    n = randi(1000)+5; % generate a random integer greater than 5 and smaller than 1006\r\n    yk = goldbach3(n);\r\n    valid(k) = (isequal(yk,sort(yk)) \u0026 all(isprime(yk)) \u0026 sum(yk)==n);\r\nend\r\nassert(all(valid));\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":108199,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":75,"test_suite_updated_at":"2017-11-18T23:12:48.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-11-14T00:05:38.000Z","updated_at":"2026-03-16T15:38:02.000Z","published_at":"2017-11-14T01:21:48.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\u003eGoldbach's strong conjecture states that every even integer greater than 2 can be expressed as the sum of two primes. For example: 4 = 2+2, 6 = 3+3, 8 = 3+5, 10 = 3+7 = 5+5, 12 = 5+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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs a corrollary, Goldbach's weak conjecture states that every odd integer greater than 7 can be expressed as the sum of three odd primes. For example: 9 = 3+3+3, 11 = 3+3+5, 13 = 3+3+7 = 3+5+5, 15 = 3+5+7 = 5+5+5 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA third conjecture was written by Goldbach in the margin of a letter, and (in its modern version) states that\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEvery integer greater than 5 can be expressed as the sum of three primes.\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\u003c/w:pPr\u003e\u003cw:r\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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e6 = 2 + 2 + 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\u003e7 = 2 + 2 + 3\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\u003e8 = 2 + 3 + 3\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\u003e9 = 2 + 2 + 5 = 3 + 3 + 3\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\u003e10 = 2 + 3 + 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\u003e11 = 2 + 2 + 7 = 3 + 3 + 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\u003e12 = 2 + 3 + 7 = 2 + 5 + 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\u003e13 = 3 + 3 + 7 = 3 + 5 + 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\u003e14 = 2 + 5 + 7\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\u003e15 = 2 + 2 + 11 = 3 + 5 + 7 = 5 + 5 + 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\u003eYour task is to write a function which takes a positive integer\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as input, and which returns a 1-by-3 vector\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, which contains three numbers that are primes and whose sum equals\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. If there exist multiple solutions for\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, then any one of those solutions will suffice. However,\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e must be in sorted order. You can assume that\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will be an integer greater than 5.\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":44476,"title":"How many unique Pythagorean triples?","description":"For a given integer |n|, return all \u003chttps://en.wikipedia.org/wiki/Pythagorean_triple Pythagorean triples\u003e that inlude numbers smaller or equal to |n|.\r\n\r\nA Pythagorean triple consist of three positive integers |{a, b, c}| such that:\r\n\r\n a \u003c b \u003c c,\r\n a^2 + b^2 = c^2\r\n\r\nThe triples should be retured in a matrix with tree columns, where each row contains a different triple. Every row needs to be sorted in ascending order ( |a| in the first column, |b| in the second and |c| in the third), and the first column must also be sorted.\r\n\r\nExample:\r\n\r\n  Input:  n   = 16\r\n  Output: mat = [3,  4, 5\r\n                 5, 12, 13 \r\n                 6,  8, 10 \r\n                 9, 12, 15]\r\n\r\nIf |n| is not an integer, or it is smaller than 5, the function should return an empty matrix.","description_html":"\u003cp\u003eFor a given integer \u003ctt\u003en\u003c/tt\u003e, return all \u003ca href = \"https://en.wikipedia.org/wiki/Pythagorean_triple\"\u003ePythagorean triples\u003c/a\u003e that inlude numbers smaller or equal to \u003ctt\u003en\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003eA Pythagorean triple consist of three positive integers \u003ctt\u003e{a, b, c}\u003c/tt\u003e such that:\u003c/p\u003e\u003cpre\u003e a \u0026lt; b \u0026lt; c,\r\n a^2 + b^2 = c^2\u003c/pre\u003e\u003cp\u003eThe triples should be retured in a matrix with tree columns, where each row contains a different triple. Every row needs to be sorted in ascending order ( \u003ctt\u003ea\u003c/tt\u003e in the first column, \u003ctt\u003eb\u003c/tt\u003e in the second and \u003ctt\u003ec\u003c/tt\u003e in the third), and the first column must also be sorted.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput:  n   = 16\r\nOutput: mat = [3,  4, 5\r\n               5, 12, 13 \r\n               6,  8, 10 \r\n               9, 12, 15]\r\n\u003c/pre\u003e\u003cp\u003eIf \u003ctt\u003en\u003c/tt\u003e is not an integer, or it is smaller than 5, the function should return an empty matrix.\u003c/p\u003e","function_template":"function mat = triples(n)\r\n    mat = [];\r\nend","test_suite":"%%\r\nfiletext = fileread('triples.m');\r\nassert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')\r\n\r\n%%\r\nn = 1;\r\nmat_correct = [];\r\nassert(isequal(triples(n),mat_correct))\r\n\r\n%%\r\nn = 20.5;\r\nmat_correct = [];\r\nassert(isequal(triples(n),mat_correct))\r\n\r\n%%\r\nn = 15;\r\nmat_correct = [3,  4, 5; 5, 12, 13; 6,  8, 10; 9, 12, 15];\r\nassert(isequal(triples(n),mat_correct))\r\n\r\n%%\r\nn = 16;\r\nmat_correct = [3,  4, 5; 5, 12, 13; 6,  8, 10; 9, 12, 15];\r\nassert(isequal(triples(n),mat_correct))\r\n\r\n%%\r\nn = 100\r\nmat_correct = ...\r\n    [3     4     5;\r\n     5    12    13;\r\n     6     8    10;\r\n     7    24    25;\r\n     8    15    17;\r\n     9    12    15;\r\n     9    40    41;\r\n    10    24    26;\r\n    11    60    61;\r\n    12    16    20;\r\n    12    35    37;\r\n    13    84    85;\r\n    14    48    50;\r\n    15    20    25;\r\n    15    36    39;\r\n    16    30    34;\r\n    16    63    65;\r\n    18    24    30;\r\n    18    80    82;\r\n    20    21    29;\r\n    20    48    52;\r\n    21    28    35;\r\n    21    72    75;\r\n    24    32    40;\r\n    24    45    51;\r\n    24    70    74;\r\n    25    60    65;\r\n    27    36    45;\r\n    28    45    53;\r\n    28    96   100;\r\n    30    40    50;\r\n    30    72    78;\r\n    32    60    68;\r\n    33    44    55;\r\n    33    56    65;\r\n    35    84    91;\r\n    36    48    60;\r\n    36    77    85;\r\n    39    52    65;\r\n    39    80    89;\r\n    40    42    58;\r\n    40    75    85;\r\n    42    56    70;\r\n    45    60    75;\r\n    48    55    73;\r\n    48    64    80;\r\n    51    68    85;\r\n    54    72    90;\r\n    57    76    95;\r\n    60    63    87;\r\n    60    80   100;\r\n    65    72    97];\r\n\r\n%%\r\nn = 1000;\r\ns_correct = [881, 3];\r\nassert(isequal(size(triples(n)), s_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":140356,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":150,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-12-31T20:29:09.000Z","updated_at":"2026-02-24T14:05:30.000Z","published_at":"2017-12-31T20:29:09.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 a given integer\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:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, return all\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://en.wikipedia.org/wiki/Pythagorean_triple\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePythagorean triples\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e that inlude numbers smaller or equal to\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:rFonts w:cs=\\\"monospace\\\"/\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA Pythagorean triple consist of three positive integers\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:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e{a, b, c}\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e such that:\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[ a \u003c b \u003c c,\\n a^2 + b^2 = c^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\u003eThe triples should be retured in a matrix with tree columns, where each row contains a different triple. Every row needs to be sorted in ascending order (\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:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in the first column,\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:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in the second and\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:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ec\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in the third), and the first column must also be sorted.\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\u003eExample:\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[Input:  n   = 16\\nOutput: mat = [3,  4, 5\\n               5, 12, 13 \\n               6,  8, 10 \\n               9, 12, 15]]]\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\u003eIf\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:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is not an integer, or it is smaller than 5, the function should return an empty matrix.\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":42807,"title":"Approximate e","description":"Given a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point numbers.\r\n\r\nExample:\r\n\r\na = 1\r\n\r\nn = 1\r\n\r\nf = 2.71828","description_html":"\u003cp\u003eGiven a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point numbers.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003ea = 1\u003c/p\u003e\u003cp\u003en = 1\u003c/p\u003e\u003cp\u003ef = 2.71828\u003c/p\u003e","function_template":"function f = approx_e(a,n)\r\n  f = a * n;\r\nend","test_suite":"%%\r\na = 1;\r\nn = 1;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = 2^18;\r\nn = 0;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = pi;\r\nn = pi;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = -exp(1);\r\nn = exp(2);\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\nfiletext = fileread('approx_e.m');\r\nassert(isempty(strfind(filetext,'exp')))\r\nassert(isempty(strfind(filetext,'str')))\r\nassert(isempty(strfind(filetext,'cat')))\r\nassert(isempty(strfind(filetext,'feval')))\r\nassert(all(cellfun(@(z)str2num(z)==round(str2num(z)),regexp(filetext,'[0123456789.]+','match'))))\r\nassert(isempty(regexp(filetext,'\\d+e')))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":15521,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2016-04-19T11:46:46.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-04-18T05:23:45.000Z","updated_at":"2026-02-19T10:15:47.000Z","published_at":"2016-04-18T05:24: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\",\"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\u003eGiven a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point 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\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ea = 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\u003en = 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\u003ef = 2.71828\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":44748,"title":"Amicable numbers","description":"Test whether two numbers are \u003chttps://en.wikipedia.org/wiki/Amicable_numbers amicable\u003e, meaning that the sum of the proper divisors of each number is equal to the other number.\r\n\r\n\r\nExample: 220 and 284 are amicable numbers because the proper divisors of 220 are 1,2,4,5,10,11,20,22,44,55,110 and their sum is 284, while the proper divisors of 284 are 1,2,4,71,142 and their sum is 220.","description_html":"\u003cp\u003eTest whether two numbers are \u003ca href = \"https://en.wikipedia.org/wiki/Amicable_numbers\"\u003eamicable\u003c/a\u003e, meaning that the sum of the proper divisors of each number is equal to the other number.\u003c/p\u003e\u003cp\u003eExample: 220 and 284 are amicable numbers because the proper divisors of 220 are 1,2,4,5,10,11,20,22,44,55,110 and their sum is 284, while the proper divisors of 284 are 1,2,4,71,142 and their sum is 220.\u003c/p\u003e","function_template":"function y = amicable(m,n)\r\n  y = false;\r\nend","test_suite":"%%\r\nm = 220; n = 284;\r\ny_correct = true;\r\nassert(isequal(amicable(m,n),y_correct))\r\n\r\n%%\r\nm = 220; n = 504;\r\ny_correct = false;\r\nassert(isequal(amicable(m,n),y_correct))\r\n\r\n%%\r\nm = 2620; n = 2924;\r\ny_correct = true;\r\nassert(isequal(amicable(m,n),y_correct))\r\n\r\n%%\r\nm = 5020; n = 5564;\r\ny_correct = true;\r\nassert(isequal(amicable(m,n),y_correct))\r\n\r\n%%\r\nm = 2924; n = 5020;\r\ny_correct = false;\r\nassert(isequal(amicable(m,n),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":4,"created_by":254267,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":78,"test_suite_updated_at":"2018-10-22T18:10:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-10-22T17:57:52.000Z","updated_at":"2026-03-16T15:34:17.000Z","published_at":"2018-10-22T18:02:09.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\u003eTest whether two numbers are\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://en.wikipedia.org/wiki/Amicable_numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eamicable\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, meaning that the sum of the proper divisors of each number is equal to the other 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:r\u003e\u003cw:t\u003eExample: 220 and 284 are amicable numbers because the proper divisors of 220 are 1,2,4,5,10,11,20,22,44,55,110 and their sum is 284, while the proper divisors of 284 are 1,2,4,71,142 and their sum is 220.\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\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}