{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":1997,"title":"Compute Fibonacci Number","description":"Compute the n-th Fibonacci Number\r\nf(0) = 0, f(1) = 1, f(2) = 1, f(3) = 2, ... f(42) = 267914296","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: 51px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 25.5px; transform-origin: 407px 25.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40.5px 8px; transform-origin: 40.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCompute the\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 67.5px 8px; transform-origin: 67.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e-th Fibonacci Number\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: 175px 8px; transform-origin: 175px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ef(0) = 0, f(1) = 1, f(2) = 1, f(3) = 2, ... f(42) = 267914296\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function f = fibonacci(n)\r\n  f = n;\r\nend","test_suite":"%%\r\nfiletext = fileread('fibonacci.m');\r\nillegal = contains(filetext, 'switch') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'if');\r\nassert(~illegal)\r\n\r\n%%\r\nassert(isequal(fibonacci(1),1))\r\nassert(isequal(fibonacci(2),1))\r\nassert(isequal(fibonacci(5),5))\r\nassert(isequal(fibonacci(7),13))\r\nassert(isequal(fibonacci(13),233))\r\nassert(isequal(fibonacci(15),610))","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":11486,"edited_by":223089,"edited_at":"2022-12-13T17:55:55.000Z","deleted_by":null,"deleted_at":null,"solvers_count":520,"test_suite_updated_at":"2022-12-13T17:55:55.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-11-16T14:45:07.000Z","updated_at":"2026-04-01T19:15:53.000Z","published_at":"2013-11-16T14:46:35.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\u003eCompute the\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-th Fibonacci 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\u003ef(0) = 0, f(1) = 1, f(2) = 1, f(3) = 2, ... f(42) = 267914296\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":2061,"title":"Narcissistic number ?","description":"Inspired by Problem 2056 created by Ted.\r\n\r\nIn recreational number theory, a narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits (Wikipedia).\r\n\r\nFor example : \r\n\r\n153 = 1^3+5^3+3^3 = 1 + 125 + 27 = 153\r\n\r\n1634 = 1^4+6^4+3^4+4^4 = 1 + 1296 + 81 + 256 = 1634 are narcissistic numbers.\r\n\r\n\r\nSimply return 1 (true) if a supplied number is narcissistic or 0 (false) if not.\r\n\r\nThe tips num2str(666)-'0' = [6 6 6] should be useful.\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eInspired by Problem 2056 created by Ted.\u003c/p\u003e\u003cp\u003eIn recreational number theory, a narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits (Wikipedia).\u003c/p\u003e\u003cp\u003eFor example :\u003c/p\u003e\u003cp\u003e153 = 1^3+5^3+3^3 = 1 + 125 + 27 = 153\u003c/p\u003e\u003cp\u003e1634 = 1^4+6^4+3^4+4^4 = 1 + 1296 + 81 + 256 = 1634 are narcissistic numbers.\u003c/p\u003e\u003cp\u003eSimply return 1 (true) if a supplied number is narcissistic or 0 (false) if not.\u003c/p\u003e\u003cp\u003eThe tips num2str(666)-'0' = [6 6 6] should be useful.\u003c/p\u003e","function_template":"function y = isnarcissistic(x)\r\n  y = sum(x);\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 9;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 10;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 99;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 152;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 153;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 154;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 371;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 370;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 1634;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 8207;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 9474;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 9926315;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 88593477;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 9800817;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 54748;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 4679307774;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 472335975;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 32164049650;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 32164049651;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 32164049652;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":351,"test_suite_updated_at":"2013-12-17T21:28:58.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-12-17T21:10:54.000Z","updated_at":"2026-03-23T05:56:25.000Z","published_at":"2013-12-17T21:28:58.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\u003eInspired by Problem 2056 created by Ted.\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\u003eIn recreational number theory, a narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits (Wikipedia).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example :\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e153 = 1^3+5^3+3^3 = 1 + 125 + 27 = 153\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\u003e1634 = 1^4+6^4+3^4+4^4 = 1 + 1296 + 81 + 256 = 1634 are narcissistic 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\u003eSimply return 1 (true) if a supplied number is narcissistic or 0 (false) if not.\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 tips num2str(666)-'0' = [6 6 6] should be useful.\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":2819,"title":"Find the 9's Complement","description":"Find the 9's complement of the given number.\r\n\r\nAn example of how this works is \u003chttp://electrical4u.com/9s-complement-and-10s-complement/  shown here\u003e.\r\n","description_html":"\u003cp\u003eFind the 9's complement of the given number.\u003c/p\u003e\u003cp\u003eAn example of how this works is \u003ca href = \"http://electrical4u.com/9s-complement-and-10s-complement/\"\u003eshown here\u003c/a\u003e.\u003c/p\u003e","function_template":"function y = nine_Comp(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 456;\r\ny_correct = 543;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 125;\r\ny_correct = 874;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 56;\r\ny_correct = 43;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 6;\r\ny_correct = 3;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 1456;\r\ny_correct = 8543;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 0;\r\ny_correct = 9;\r\nassert(isequal(nine_Comp(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":352,"test_suite_updated_at":"2015-01-09T12:45:34.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2015-01-09T12:42:55.000Z","updated_at":"2026-02-16T10:13:55.000Z","published_at":"2015-01-09T12:42:55.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the 9's complement of the given 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\u003eAn example of how this works is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://electrical4u.com/9s-complement-and-10s-complement/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eshown here\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2733,"title":"Evil Number","description":"Check if a given natural number is evil or not. \r\n\r\nRead more at \u003chttps://oeis.org/A001969 OEIS\u003e.","description_html":"\u003cp\u003eCheck if a given natural number is evil or not.\u003c/p\u003e\u003cp\u003eRead more at \u003ca href = \"https://oeis.org/A001969\"\u003eOEIS\u003c/a\u003e.\u003c/p\u003e","function_template":"function tf = isevil(n)\r\n  tf = ;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = false;\r\nassert(isequal(isevil(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = true;\r\nassert(isequal(isevil(x),y_correct))\r\n%%\r\nx = [18, 20, 23, 24, 27, 45, 46, 48, 96, 99, 123,];\r\ny_correct = true;\r\nassert(isequal(all(arrayfun(@isevil,x)),y_correct))\r\n%%\r\nx = [14, 16, 19, 37, 38, 55, 56, 59, 62,  79, 82, 91, 93, 94, 97, 98, 117, 118, 121];\r\ny_correct = false;\r\nassert(isequal(any(arrayfun(@isevil,x)),y_correct))\r\n%%\r\nx = 2^randi([5 10])+1;\r\ny_correct = true;\r\nassert(isequal(isevil(x),y_correct))\r\n\r\n%%\r\n% more test cases may be introduced\r\n%%\r\n% DISABLED\r\n% ________'FAIR'_SCORING_SYSTEM______________\r\n%\r\n% This section scores for usage of ans\r\n% and strings, which are common methods \r\n% to reduce cody size of solution.\r\n% Here, strings are threated like vectors.\r\n% Please do not hack it, as this problem\r\n% is not mentioned to be a hacking problem.\r\n% \r\n  try\r\n% disable:\r\nassert(false) \r\n%\r\n  size_old = feval(@evalin,'caller','score');\r\n%\r\n  all_nodes = mtree('isevil.m','-file');\r\n  str_nodes = mtfind(all_nodes,'Kind','STRING');\r\n   eq_nodes = mtfind(all_nodes,'Kind','EQUALS');\r\nprint_nodes = mtfind(all_nodes,'Kind','PRINT');\r\n expr_nodes = mtfind(all_nodes,'Kind','EXPR');\r\n%\r\n       size = count(all_nodes)           ...\r\n              +sum(str_nodes.nodesize-1) ...\r\n              +2*(count(expr_nodes)      ...\r\n                  +count(print_nodes)    ...\r\n                  -count(eq_nodes));\r\n%\r\n  feval(@assignin,'caller','score',size);\r\n%\r\n  fprintf('Size in standard cody scoring is %i.\\n',size_old);\r\n  fprintf('Here it is %i.\\n',size);\r\n  end\r\n%\r\n%_________RESULT_____________________________","published":true,"deleted":false,"likes_count":3,"comments_count":6,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":274,"test_suite_updated_at":"2016-12-26T10:21:47.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-12-07T21:50:01.000Z","updated_at":"2026-03-11T15:15:47.000Z","published_at":"2015-01-19T12:47:58.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\u003eCheck if a given natural number is evil or not.\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\u003eRead more at\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://oeis.org/A001969\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEIS\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":156,"title":"Parasitic numbers","description":"Test whether the first input x is an n-parasitic number: \u003chttp://en.wikipedia.org/wiki/Parasitic_number\u003e. ( _n_ is the second input.)\r\n\r\nExamples:\r\n\r\nparasitic(128205,4) ---\u003e true\r\n\r\nparasitic(179487,4) ---\u003e true\r\n\r\nparasitic(179487,3) ---\u003e false","description_html":"\u003cp\u003eTest whether the first input x is an n-parasitic number: \u003ca href=\"http://en.wikipedia.org/wiki/Parasitic_number\"\u003ehttp://en.wikipedia.org/wiki/Parasitic_number\u003c/a\u003e. ( \u003ci\u003en\u003c/i\u003e is the second input.)\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cp\u003eparasitic(128205,4) ---\u003e true\u003c/p\u003e\u003cp\u003eparasitic(179487,4) ---\u003e true\u003c/p\u003e\u003cp\u003eparasitic(179487,3) ---\u003e false\u003c/p\u003e","function_template":"function y = parasitic(x,n)\r\n  y = x*n;\r\nend","test_suite":"%%\r\nx = 128205;\r\nn = 4\r\ny_correct = true;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 179487;\r\nn = 4;\r\ny_correct = true;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 179487;\r\nn = 3;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142857;\r\nn = 5;\r\ny_correct = true;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142857;\r\nn = 4;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142657;\r\nn = 5;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142857;\r\nn = 4;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 1012658227848;\r\nn = 8;\r\ny_correct = true;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 1012658227848;\r\nn = 4;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142857;\r\nn = 7;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 12;\r\nn = 2;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":5,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":315,"test_suite_updated_at":"2016-09-30T20:15:58.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2012-01-29T03:38:27.000Z","updated_at":"2026-03-11T15:14:37.000Z","published_at":"2012-01-29T03:38:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 the first input x is an n-parasitic 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=\\\"http://en.wikipedia.org/wiki/Parasitic_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Parasitic_number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (\u003c/w:t\u003e\u003c/w:r\u003e\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 is the second input.)\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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eparasitic(128205,4) ---\u0026gt; true\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\u003eparasitic(179487,4) ---\u0026gt; true\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\u003eparasitic(179487,3) ---\u0026gt; false\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":139,"title":"Determine if a Given Number is a Triangle Number","description":"*Description:*\r\n\r\nDetermine if the elements of an input array are triangle numbers and return the result as an array with the same dimensions as the input.\r\n\r\n*Example:*\r\n\r\n    Input  = [ 1 2 3 ];\r\n    Output = [ 1 0 1 ];","description_html":"\u003cp\u003e\u003cb\u003eDescription:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eDetermine if the elements of an input array are triangle numbers and return the result as an array with the same dimensions as the input.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cpre\u003e    Input  = [ 1 2 3 ];\r\n    Output = [ 1 0 1 ];\u003c/pre\u003e","function_template":"function y = isTriangleNumber(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1:100;\r\ny_correct = false(1,100);\r\ny_correct([1 3 6 10 15 21 28 36 45 55 66 78 91]) = true;\r\nassert(isequal(isTriangleNumber(x),y_correct))\r\n\r\n%%\r\nx = 1;\r\ny_correct = true;\r\nassert(isequal(isTriangleNumber(x),y_correct))\r\n\r\n%%\r\nx = [4912734125;4912734126];\r\ny_correct = [false;true];\r\nassert(isequal(isTriangleNumber(x),y_correct))","published":true,"deleted":false,"likes_count":8,"comments_count":0,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":398,"test_suite_updated_at":"2012-01-28T09:07:10.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2012-01-28T09:05:06.000Z","updated_at":"2026-02-16T10:37:35.000Z","published_at":"2012-01-28T09:10:17.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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eDescription:\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\u003eDetermine if the elements of an input array are triangle numbers and return the result as an array with the same dimensions as the input.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    Input  = [ 1 2 3 ];\\n    Output = [ 1 0 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":2056,"title":"Is this number Munchhausen?","description":"In this problem, simply return 1 if a supplied number is Munchhausen or 0 if not.\r\nExample\r\n153 is narcissistic but not a Munchhausen number\r\nNOTE: the convention is that 0^0=0","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: 111px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 55.5px; transform-origin: 407px 55.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 250px 8px; transform-origin: 250px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn this problem, simply return 1 if a supplied number is Munchhausen or 0 if not.\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: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\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: 158px 8px; transform-origin: 158px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e153 is narcissistic but not a Munchhausen number\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: 111px 8px; transform-origin: 111px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNOTE: the convention is that 0^0=0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = ismunch(n)\r\n  tf='?';\r\nend","test_suite":"%%\r\nn=1;\r\ny_correct=1;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=0;\r\ny_correct=1;\r\nassert(isequal(ismunch(n),y_correct))\r\n\r\n%%\r\nn=153;\r\ny_correct=0;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=634;\r\ny_correct=0;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=3435;\r\ny_correct=1;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=3534;\r\ny_correct=0;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=438579088;\r\ny_correct=1;\r\nassert(isequal(ismunch(n),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":9,"created_by":17471,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":211,"test_suite_updated_at":"2013-12-15T12:28:07.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-12-15T12:06:13.000Z","updated_at":"2026-02-16T10:17:09.000Z","published_at":"2013-12-15T12:28:07.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\u003eIn this problem, simply return 1 if a supplied number is Munchhausen or 0 if not.\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\u003e153 is narcissistic but not a Munchhausen 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\u003eNOTE: the convention is that 0^0=0\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":1771,"title":"Polygonal numbers","description":"The task of \u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/5 Problem 5\u003e is to calculate triangular numbers. By playing with dots we can produce also square numbers like:\r\n\r\n                                 * * * *\r\n                     * * *       * * * *\r\n           * *       * * *       * * * *\r\n1: *    4: * *    9: * * *   16: * * * *\r\n\r\nor hexagonal numbers:\r\n\r\n                                          * * * *\r\n                                         *       *\r\n                         * * *          * * * *   *\r\n                        *     *        * *     *   *\r\n            * *        * * *   *        * * *   * * \r\n           *   *        *   * *          *   * * *\r\n1: *    6:  * *    15:   * * *       28:  * * * *\r\n\r\n\u0026nbsp\r\n\r\nAccording to those rules we can create \u003chttp://en.wikipedia.org/wiki/Polygonal_number polygonal numbers\u003e for all regular polygons.\r\n\r\n\u0026nbsp\r\n\r\nYour task: given _S_ and _N_ *calculate _N_-th _S_-gonal numbers* _P(S,N)_ \r\n\r\n\u0026nbsp\r\n\r\nExamples:\r\n\r\n# _P(4, 3)_ returns _[9]_    because 3-rd square number is 9,\r\n# _P(3, 1:5)_ returns _[1, 3, 6, 10, 15]_   first 5 triangular numbers,\r\n# _P(3:6, 4)_ returns _[10, 16, 22, 28]_   4-th triangular, square, pentagonal and hexagonal numbers,\r\n# _P([3, 4], [1; 2])_ returns _[1, 1; 3, 4]_.\r\n\r\nsee the test suite for more hints","description_html":"\u003cp\u003eThe task of \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/5\"\u003eProblem 5\u003c/a\u003e is to calculate triangular numbers. By playing with dots we can produce also square numbers like:\u003c/p\u003e\u003cpre\u003e                                 * * * *\r\n                     * * *       * * * *\r\n           * *       * * *       * * * *\r\n1: *    4: * *    9: * * *   16: * * * *\u003c/pre\u003e\u003cp\u003eor hexagonal numbers:\u003c/p\u003e\u003cpre\u003e                                          * * * *\r\n                                         *       *\r\n                         * * *          * * * *   *\r\n                        *     *        * *     *   *\r\n            * *        * * *   *        * * *   * * \r\n           *   *        *   * *          *   * * *\r\n1: *    6:  * *    15:   * * *       28:  * * * *\u003c/pre\u003e\u003cp\u003e\u0026nbsp\u003c/p\u003e\u003cp\u003eAccording to those rules we can create \u003ca href = \"http://en.wikipedia.org/wiki/Polygonal_number\"\u003epolygonal numbers\u003c/a\u003e for all regular polygons.\u003c/p\u003e\u003cp\u003e\u0026nbsp\u003c/p\u003e\u003cp\u003eYour task: given \u003ci\u003eS\u003c/i\u003e and \u003ci\u003eN\u003c/i\u003e \u003cb\u003ecalculate \u003ci\u003eN\u003c/i\u003e-th \u003ci\u003eS\u003c/i\u003e-gonal numbers\u003c/b\u003e \u003ci\u003eP(S,N)\u003c/i\u003e\u003c/p\u003e\u003cp\u003e\u0026nbsp\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003col\u003e\u003cli\u003e\u003ci\u003eP(4, 3)\u003c/i\u003e returns \u003ci\u003e[9]\u003c/i\u003e    because 3-rd square number is 9,\u003c/li\u003e\u003cli\u003e\u003ci\u003eP(3, 1:5)\u003c/i\u003e returns \u003ci\u003e[1, 3, 6, 10, 15]\u003c/i\u003e   first 5 triangular numbers,\u003c/li\u003e\u003cli\u003e\u003ci\u003eP(3:6, 4)\u003c/i\u003e returns \u003ci\u003e[10, 16, 22, 28]\u003c/i\u003e   4-th triangular, square, pentagonal and hexagonal numbers,\u003c/li\u003e\u003cli\u003e\u003ci\u003eP([3, 4], [1; 2])\u003c/i\u003e returns \u003ci\u003e[1, 1; 3, 4]\u003c/i\u003e.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003esee the test suite for more hints\u003c/p\u003e","function_template":"function y = P(s,n)\r\n  y = s*n;\r\nend","test_suite":"%%\r\nassert(P(4,3)==9)\r\n%%\r\ns=3;\r\nn=1:5;\r\ny_correct=[1 3 6 10 15];\r\nassert(isequal(P(s,n),y_correct))\r\n%%\r\ns=3:6;\r\nn=4;\r\nY_correct=[10 16 22 28];\r\nassert(isequal(P(s,n),Y_correct))\r\n%%\r\ns=randi([3 1000],1,10);\r\nn=1;\r\ny_correct=ones(1,10);\r\nassert(isequal(P(s,n),y_correct))\r\n%%\r\ns=randi(1000,1,10)+2;\r\nn=5;\r\ny_correct=10*s-15;\r\nassert(isequal(P(s,n),y_correct))\r\n%%\r\ns=[5 6 7]';\r\nn=[2 8 9];\r\ny_correct=[5 92 117;6 120 153;7 148 189];\r\nassert(isequal(P(s,n),y_correct))\r\n%%\r\n% for M.Z.\r\ns=[5 6 7]';\r\nn=[2 8 9];\r\ny_correct=[5 92 117;6 120 153;7 148 189];\r\nassert(isequal(P(flipud(s),n),flipud(y_correct)))\r\n%%\r\ns=randi([3,1000]);\r\nn=randi([3,1000]);\r\nassert(P(s+1,n+1)-P(s,n+1)==P(3,n))\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":4,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":138,"test_suite_updated_at":"2016-10-15T05:56:15.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2013-08-02T13:16:29.000Z","updated_at":"2026-02-16T10:32:51.000Z","published_at":"2013-08-02T23:34:24.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\u003eThe task of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/cody/problems/5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is to calculate triangular numbers. By playing with dots we can produce also square numbers like:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[                                 * * * *\\n                     * * *       * * * *\\n           * *       * * *       * * * *\\n1: *    4: * *    9: * * *   16: * * * *]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eor hexagonal numbers:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[                                          * * * *\\n                                         *       *\\n                         * * *          * * * *   *\\n                        *     *        * *     *   *\\n            * *        * * *   *        * * *   * * \\n           *   *        *   * *          *   * * *\\n1: *    6:  * *    15:   * * *       28:  * * * *]]\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\u003e\u0026amp;nbsp\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\u003eAccording to those rules we can create\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Polygonal_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003epolygonal numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for all regular polygons.\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\u0026amp;nbsp\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: given\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\u003eS\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw: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 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecalculate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e-th\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eS\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e-gonal numbers\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\u003eP(S,N)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026amp;nbsp\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP(4, 3)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns\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\u003e[9]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e because 3-rd square number is 9,\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP(3, 1:5)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns\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\u003e[1, 3, 6, 10, 15]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e first 5 triangular numbers,\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP(3:6, 4)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns\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\u003e[10, 16, 22, 28]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 4-th triangular, square, pentagonal and hexagonal numbers,\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP([3, 4], [1; 2])\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns\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\u003e[1, 1; 3, 4]\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\u003esee the test suite for more hints\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":2690,"title":"Armstrong Number","description":"Determine whether the given input n-digit number is Armstrong Number or not.\r\nReturn True if it is an Armstrong Number. An n-Digit Armstrong number is an integer such that the sum of the power n of its digit is equal to the number itself.\r\nFor Example:\r\n 371 = 3^3 + 7^3 + 1^3  or \r\n 1741725 = 1^7 + 7^7 + 4^7 + 1^7 + 7^7 + 2^7 + 5^7","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: 152.867px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 76.4333px; transform-origin: 407px 76.4333px; 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: 246px 8px; transform-origin: 246px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eDetermine whether the given input n-digit number is Armstrong Number or not.\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: 378px 8px; transform-origin: 378px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn True if it is an Armstrong Number. An n-Digit Armstrong number is an integer such that the sum of the power n of its digit is equal to the number itself.\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: 41.5px 8px; transform-origin: 41.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor Example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 108px 8.5px; tab-size: 4; transform-origin: 108px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e 371 = 3^3 + 7^3 + 1^3  or \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 200px 8.5px; tab-size: 4; transform-origin: 200px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e 1741725 = 1^7 + 7^7 + 4^7 + 1^7 + 7^7 + 2^7 + 5^7\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = Armstrong(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 9;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 371;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 24;\r\ny_correct = 0;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 407;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 1634;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 68955;\r\ny_correct = 0;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 11;\r\ny_correct = 0;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 548834;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 1741725;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":8,"comments_count":2,"created_by":32100,"edited_by":223089,"edited_at":"2022-11-19T15:34:07.000Z","deleted_by":null,"deleted_at":null,"solvers_count":356,"test_suite_updated_at":"2022-11-19T15:34:07.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2014-11-25T09:16:05.000Z","updated_at":"2026-02-16T10:19:41.000Z","published_at":"2014-11-25T09:16:36.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\u003eDetermine whether the given input n-digit number is Armstrong Number or not.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn True if it is an Armstrong Number. An n-Digit Armstrong number is an integer such that the sum of the power n of its digit is equal to the number itself.\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:\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[ 371 = 3^3 + 7^3 + 1^3  or \\n 1741725 = 1^7 + 7^7 + 4^7 + 1^7 + 7^7 + 2^7 + 5^7]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2593,"title":"Polite numbers. N-th polite number.","description":"A polite number is an integer that sums of at least two consecutive positive integers.\r\n\r\nFor example _7 = 3+4_ so 7 is a polite number.\r\n\r\nGiven _N_ return N-th polite number.\r\n\r\nSee also \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2595 2595\u003e","description_html":"\u003cp\u003eA polite number is an integer that sums of at least two consecutive positive integers.\u003c/p\u003e\u003cp\u003eFor example \u003ci\u003e7 = 3+4\u003c/i\u003e so 7 is a polite number.\u003c/p\u003e\u003cp\u003eGiven \u003ci\u003eN\u003c/i\u003e return N-th polite number.\u003c/p\u003e\u003cp\u003eSee also \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2595\"\u003e2595\u003c/a\u003e\u003c/p\u003e","function_template":"function polite = Nth_polite(n)\r\n  polite = n;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 3;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 5;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 4;\r\ny_correct = 7;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 9;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 7;\r\ny_correct = 11;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 11;\r\ny_correct = 15;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 12;\r\ny_correct = 17;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 14;\r\ny_correct = 19;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 19;\r\ny_correct = 24;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 21;\r\ny_correct = 26;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 27;\r\ny_correct = 33;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 64;\r\ny_correct = 71;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 1e6;\r\ny_correct = x+20;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 1e7;\r\ny_correct = x+24;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 999999999;\r\ny_correct = x+30;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":166,"test_suite_updated_at":"2014-09-17T10:56:47.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2014-09-16T22:44:09.000Z","updated_at":"2026-02-16T10:31:08.000Z","published_at":"2014-09-17T10:56:47.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA polite number is an integer that sums of at least two consecutive positive integers.\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\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\u003e7 = 3+4\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e so 7 is a polite 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\u003eGiven\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 return N-th polite 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\u003eSee also\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2595\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e2595\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":2734,"title":"N-th Odious","description":"Given index n return n-th \u003chttps://oeis.org/A000069 odious number\u003e.","description_html":"\u003cp\u003eGiven index n return n-th \u003ca href = \"https://oeis.org/A000069\"\u003eodious number\u003c/a\u003e.\u003c/p\u003e","function_template":"function y = nthodious(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 2;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = 4;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 9;\r\ny_correct = 16;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 17;\r\ny_correct = 32;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 33;\r\ny_correct = 64;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 65;\r\ny_correct = 128;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 3387;\r\ny_correct = 6772;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 22;\r\ny_correct = 42;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 1e5;\r\ny_correct = 2e5-1;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\n% more test cases may be introduced\r\n%%\r\n% DISABLED\r\n% ________'FAIR'_SCORING_SYSTEM______________\r\n%\r\n% This section scores for usage of ans\r\n% and strings, which are common methods \r\n% to reduce cody size of solution.\r\n% Here, strings are threated like vectors.\r\n% Please do not hack it, as this problem\r\n% is not mentioned to be a hacking problem.\r\n% \r\n  try\r\nassert(false)\r\n% \r\n  size_old = feval(@evalin,'caller','score');\r\n%\r\n  all_nodes = mtree('nthodious.m','-file');\r\n  str_nodes = mtfind(all_nodes,'Kind','STRING');\r\n   eq_nodes = mtfind(all_nodes,'Kind','EQUALS');\r\nprint_nodes = mtfind(all_nodes,'Kind','PRINT');\r\n expr_nodes = mtfind(all_nodes,'Kind','EXPR');\r\n%\r\n       size = count(all_nodes)           ...\r\n              +sum(str_nodes.nodesize-1) ...\r\n              +2*(count(expr_nodes)      ...\r\n                  +count(print_nodes)    ...\r\n                  -count(eq_nodes));\r\n%\r\n  feval(@assignin,'caller','score',size);\r\n%\r\n  fprintf('Size in standard cody scoring is %i.\\n',size_old);\r\n  fprintf('Here it is %i.\\n',size);\r\n  end\r\n%\r\n%_________RESULT_____________________________\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":182,"test_suite_updated_at":"2015-01-19T23:07:07.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-12-07T21:50:54.000Z","updated_at":"2026-02-16T10:22:49.000Z","published_at":"2015-01-19T13:39:11.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 index n return n-th\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://oeis.org/A000069\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eodious number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":166,"title":"Kaprekar numbers","description":"Test if the input is a Kaprekar number: \u003chttp://mathworld.wolfram.com/KaprekarNumber.html\u003e. Return a logical true or false.\r\n\r\n\r\n","description_html":"\u003cp\u003eTest if the input is a Kaprekar number: \u003ca href=\"http://mathworld.wolfram.com/KaprekarNumber.html\"\u003ehttp://mathworld.wolfram.com/KaprekarNumber.html\u003c/a\u003e. Return a logical true or false.\u003c/p\u003e","function_template":"function tf = kap(x)\r\n  tf = maybe;\r\nend","test_suite":"%%\r\nx = 16;\r\ntf_correct = false;\r\nassert(isequal(kap(x),tf_correct))\r\n\r\n%%\r\nx = 704;\r\ntf_correct = false;\r\nassert(isequal(kap(x),tf_correct))\r\n\r\n%%\r\nx = 9\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 45\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 55\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 99\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 297\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 703\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 999\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 2223\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 2728\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 4950\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 5050\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 7272\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 7777\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 9999\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 17344\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 22222\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 77778\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 82656\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 95121\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 99999\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 142857\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 148149\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 181819\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 187110\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 208495\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 318682\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 329967\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 351352\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 356643\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 390313\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 461539\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 466830\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 499500\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 500500\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 533170\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 538461\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 609687\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 643357\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 648648\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 670033\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 681318\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 681319\r\ntf_correct = false\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 681320\r\ntf_correct = false\r\nassert(isequal(kap(x),tf_correct))","published":true,"deleted":false,"likes_count":5,"comments_count":2,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":294,"test_suite_updated_at":"2016-06-14T14:57:02.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2012-01-29T16:05:57.000Z","updated_at":"2026-02-16T10:34:39.000Z","published_at":"2012-01-29T16:05:57.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 if the input is a Kaprekar 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=\\\"http://mathworld.wolfram.com/KaprekarNumber.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://mathworld.wolfram.com/KaprekarNumber.html\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Return a logical true or false.\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":2248,"title":"Bell Number calculator","description":"Calculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the Wikipedia entry for Bell Number.\r\nExample\r\n Belln(8) = [1 1 2 5 15 52 203 877 4140]","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: 102.433px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 51.2167px; transform-origin: 407px 51.2167px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 374px 8px; transform-origin: 374px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWikipedia entry for Bell Number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 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: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 160px 8.5px; transform-origin: 160px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Belln(8) = [1 1 2 5 15 52 203 877 4140]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = Belln(n)\r\n  y = [1:x];\r\nend","test_suite":"%%\r\nn = 0;\r\ny_correct = 1;\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 5;\r\ny_correct = [1 1 2 5 15 52];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 10;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 13;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975 678570 4213597 27644437];\r\nassert(isequal(Belln(n),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":23893,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":191,"test_suite_updated_at":"2021-06-16T09:39:43.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-03-14T09:59:39.000Z","updated_at":"2026-02-16T10:15:53.000Z","published_at":"2014-03-14T10:09:41.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\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia entry for Bell Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[ Belln(8) = [1 1 2 5 15 52 203 877 4140]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1472,"title":"nth Rational Number","description":"Return the nth rational number.\r\nThis is the inverse to Problem 1471. Index of a Rational number\r\nThe first ten positive rational numbers under the enumeration using cantors diagonalization argument are 1/1, 2/1, 1/2, 3/1, 2/2, 1/3, 4/1, 3/2, 2/3, 1/4.\r\nFind the index of a positive rational number enumerated in this manner, i.e. the 6th rational number is 1/3.\r\nProblem 2) Prev: 1471 Next: 1477","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: 162px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 81px; transform-origin: 407px 81px; 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: 98.5px 8px; transform-origin: 98.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn the nth rational number.\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: 93.5px 8px; transform-origin: 93.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis is the inverse to Problem\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e1471\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 88.5px 8px; transform-origin: 88.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Index of a Rational number\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: 375px 8px; transform-origin: 375px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe first ten positive rational numbers under the enumeration using cantors diagonalization argument are 1/1, 2/1, 1/2, 3/1, 2/2, 1/3, 4/1, 3/2, 2/3, 1/4.\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: 332px 8px; transform-origin: 332px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFind the index of a positive rational number enumerated in this manner, i.e. the 6th rational number is 1/3.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 53px 8px; transform-origin: 53px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eProblem 2) Prev:\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e1471\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 17.5px 8px; transform-origin: 17.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e Next:\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e1477\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function out = cantor_index2rational(x)\r\np=1; q=1;\r\nout=[p q]\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = [1 1];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = [2 1];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 6;\r\ny_correct = [1 3];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 385;\r\ny_correct = [22 7];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx=108924;\r\ny_correct = [355 113];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 206;\r\ny_correct = [5 16];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 2060;\r\ny_correct = [21 44];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 20604;\r\ny_correct = [103 101];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 20704;\r\ny_correct = [3 201];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 205704;\r\ny_correct = [58 584];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 2085704;\r\ny_correct = [200 1843];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 20851704;\r\ny_correct = [4408 2051];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 290851704;\r\ny_correct = [23437 683];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":11275,"edited_by":223089,"edited_at":"2022-11-29T16:44:48.000Z","deleted_by":null,"deleted_at":null,"solvers_count":172,"test_suite_updated_at":"2022-11-29T16:44:48.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-04-30T02:37:22.000Z","updated_at":"2026-02-16T10:20:29.000Z","published_at":"2013-04-30T02:37:22.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\u003eReturn the nth rational 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\u003eThis is the inverse to Problem\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e1471\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Index of a Rational 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\u003eThe first ten positive rational numbers under the enumeration using cantors diagonalization argument are 1/1, 2/1, 1/2, 3/1, 2/2, 1/3, 4/1, 3/2, 2/3, 1/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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the index of a positive rational number enumerated in this manner, i.e. the 6th rational number is 1/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\u003eProblem 2) Prev:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e1471\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e Next:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e1477\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2595,"title":"Polite numbers. Politeness.","description":"A polite number is an integer that sums of two or more consecutive positive integers.\r\nPoliteness of a positive integer is a number of nontrivial ways to write n as a sum of two or more consecutive positive integers.\r\n\r\nFor example _9 = 4+5 = 2+3+4_  and politeness of 9 is 2.\r\n\r\nGiven _N_ return politeness of _N_.\r\n\r\nSee also \u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/2593 2593\u003e","description_html":"\u003cp\u003eA polite number is an integer that sums of two or more consecutive positive integers.\r\nPoliteness of a positive integer is a number of nontrivial ways to write n as a sum of two or more consecutive positive integers.\u003c/p\u003e\u003cp\u003eFor example \u003ci\u003e9 = 4+5 = 2+3+4\u003c/i\u003e  and politeness of 9 is 2.\u003c/p\u003e\u003cp\u003eGiven \u003ci\u003eN\u003c/i\u003e return politeness of \u003ci\u003eN\u003c/i\u003e.\u003c/p\u003e\u003cp\u003eSee also \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/2593\"\u003e2593\u003c/a\u003e\u003c/p\u003e","function_template":"function P = politeness(N)\r\n  P=N;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 0;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = 1;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 7;\r\ny_correct = 1;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 9;\r\ny_correct = 2;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 15;\r\ny_correct = 3;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 18;\r\ny_correct = 2;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 21;\r\ny_correct = 3;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 1024;\r\ny_correct = 0;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 1025;\r\ny_correct = 5;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 25215;\r\ny_correct = 11;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 62;\r\ny_correct = 1;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 63;\r\ny_correct = 5;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 65;\r\ny_correct = 3;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\n% anti-lookup \u0026 clue\r\nnums=primes(200);\r\npattern=[1 nums([false ~randi([0 25],1,45)])];\r\nx=prod(pattern)*2^randi([0 5]);\r\ny_correct=2^numel(pattern)/2-1;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nfor k=randi(2e4,1,20)\r\n  assert(isequal(politeness(k*(k-1))+1,(politeness(k)+1)*(politeness(k-1)+1)))\r\nend","published":true,"deleted":false,"likes_count":8,"comments_count":6,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":186,"test_suite_updated_at":"2014-09-17T15:38:21.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2014-09-16T22:47:12.000Z","updated_at":"2026-02-16T10:30:04.000Z","published_at":"2014-09-17T10:56: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\u003eA polite number is an integer that sums of two or more consecutive positive integers. Politeness of a positive integer is a number of nontrivial ways to write n as a sum of two or more consecutive positive integers.\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\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\u003e9 = 4+5 = 2+3+4\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and politeness of 9 is 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\u003eGiven\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 return politeness of\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.\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 also\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/cody/problems/2593\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e2593\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":1925,"title":"Smith numbers","description":"Return true if the input is a Smith number in base ten. Otherwise, return false. Read about Smith numbers at http://en.wikipedia.org/wiki/Smith_number.\r\nA Smith number must be positive and have more than one factor.","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: 72px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.5px 36px; transform-origin: 406.5px 36px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 383.5px 21px; text-align: left; transform-origin: 383.5px 21px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 348.958px 7.81667px; transform-origin: 348.958px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn true if the input is a Smith number in base ten. Otherwise, return false. Read about Smith numbers at\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: 2.23333px 7.81667px; transform-origin: 2.23333px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Smith_number\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ehttp://en.wikipedia.org/wiki/Smith_number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2.23333px 7.81667px; transform-origin: 2.23333px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 383.5px 10.5px; text-align: left; transform-origin: 383.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 208.258px 7.81667px; transform-origin: 208.258px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA Smith number must be positive and have more than one factor.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = isSmith(x)\r\n  tf = false;\r\nend","test_suite":"%%\r\nx = 4;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 265;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 588;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 1086;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 4937775;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 5;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 1000;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 94.1;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 202.689;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = pi;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = -4;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 11^2;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n\r\n%%\r\nx = 9^3;\r\ny = [-1 0 1];\r\ntf=true;\r\nfor k=1:numel(x)\r\n    tf=tf\u0026\u0026isequal(isSmith(x(k)+y(k)), y(k)\u003c1)\r\nend\r\nassert(isequal(tf, true))","published":true,"deleted":false,"likes_count":5,"comments_count":0,"created_by":10139,"edited_by":223089,"edited_at":"2024-08-04T06:35:24.000Z","deleted_by":null,"deleted_at":null,"solvers_count":776,"test_suite_updated_at":"2024-08-04T06:35:24.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-10-09T12:32:02.000Z","updated_at":"2026-01-12T18:27:18.000Z","published_at":"2013-10-09T12:32:07.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\u003eReturn true if the input is a Smith number in base ten. Otherwise, return false. Read about Smith numbers at\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/Smith_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Smith_number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA Smith number must be positive and have more than one factor.\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\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":1997,"title":"Compute Fibonacci Number","description":"Compute the n-th Fibonacci Number\r\nf(0) = 0, f(1) = 1, f(2) = 1, f(3) = 2, ... f(42) = 267914296","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: 51px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 25.5px; transform-origin: 407px 25.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40.5px 8px; transform-origin: 40.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCompute the\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 67.5px 8px; transform-origin: 67.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e-th Fibonacci Number\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: 175px 8px; transform-origin: 175px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ef(0) = 0, f(1) = 1, f(2) = 1, f(3) = 2, ... f(42) = 267914296\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function f = fibonacci(n)\r\n  f = n;\r\nend","test_suite":"%%\r\nfiletext = fileread('fibonacci.m');\r\nillegal = contains(filetext, 'switch') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'if');\r\nassert(~illegal)\r\n\r\n%%\r\nassert(isequal(fibonacci(1),1))\r\nassert(isequal(fibonacci(2),1))\r\nassert(isequal(fibonacci(5),5))\r\nassert(isequal(fibonacci(7),13))\r\nassert(isequal(fibonacci(13),233))\r\nassert(isequal(fibonacci(15),610))","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":11486,"edited_by":223089,"edited_at":"2022-12-13T17:55:55.000Z","deleted_by":null,"deleted_at":null,"solvers_count":520,"test_suite_updated_at":"2022-12-13T17:55:55.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-11-16T14:45:07.000Z","updated_at":"2026-04-01T19:15:53.000Z","published_at":"2013-11-16T14:46:35.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\u003eCompute the\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-th Fibonacci 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\u003ef(0) = 0, f(1) = 1, f(2) = 1, f(3) = 2, ... f(42) = 267914296\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":2061,"title":"Narcissistic number ?","description":"Inspired by Problem 2056 created by Ted.\r\n\r\nIn recreational number theory, a narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits (Wikipedia).\r\n\r\nFor example : \r\n\r\n153 = 1^3+5^3+3^3 = 1 + 125 + 27 = 153\r\n\r\n1634 = 1^4+6^4+3^4+4^4 = 1 + 1296 + 81 + 256 = 1634 are narcissistic numbers.\r\n\r\n\r\nSimply return 1 (true) if a supplied number is narcissistic or 0 (false) if not.\r\n\r\nThe tips num2str(666)-'0' = [6 6 6] should be useful.\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eInspired by Problem 2056 created by Ted.\u003c/p\u003e\u003cp\u003eIn recreational number theory, a narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits (Wikipedia).\u003c/p\u003e\u003cp\u003eFor example :\u003c/p\u003e\u003cp\u003e153 = 1^3+5^3+3^3 = 1 + 125 + 27 = 153\u003c/p\u003e\u003cp\u003e1634 = 1^4+6^4+3^4+4^4 = 1 + 1296 + 81 + 256 = 1634 are narcissistic numbers.\u003c/p\u003e\u003cp\u003eSimply return 1 (true) if a supplied number is narcissistic or 0 (false) if not.\u003c/p\u003e\u003cp\u003eThe tips num2str(666)-'0' = [6 6 6] should be useful.\u003c/p\u003e","function_template":"function y = isnarcissistic(x)\r\n  y = sum(x);\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 9;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 10;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 99;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 152;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 153;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 154;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 371;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 370;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 1634;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 8207;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 9474;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 9926315;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 88593477;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 9800817;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 54748;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 4679307774;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 472335975;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 32164049650;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 32164049651;\r\ny_correct = true;\r\nassert(isequal(isnarcissistic(x),y_correct))\r\n%%\r\nx = 32164049652;\r\ny_correct = false;\r\nassert(isequal(isnarcissistic(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":351,"test_suite_updated_at":"2013-12-17T21:28:58.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-12-17T21:10:54.000Z","updated_at":"2026-03-23T05:56:25.000Z","published_at":"2013-12-17T21:28:58.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\u003eInspired by Problem 2056 created by Ted.\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\u003eIn recreational number theory, a narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits (Wikipedia).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example :\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e153 = 1^3+5^3+3^3 = 1 + 125 + 27 = 153\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\u003e1634 = 1^4+6^4+3^4+4^4 = 1 + 1296 + 81 + 256 = 1634 are narcissistic 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\u003eSimply return 1 (true) if a supplied number is narcissistic or 0 (false) if not.\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 tips num2str(666)-'0' = [6 6 6] should be useful.\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":2819,"title":"Find the 9's Complement","description":"Find the 9's complement of the given number.\r\n\r\nAn example of how this works is \u003chttp://electrical4u.com/9s-complement-and-10s-complement/  shown here\u003e.\r\n","description_html":"\u003cp\u003eFind the 9's complement of the given number.\u003c/p\u003e\u003cp\u003eAn example of how this works is \u003ca href = \"http://electrical4u.com/9s-complement-and-10s-complement/\"\u003eshown here\u003c/a\u003e.\u003c/p\u003e","function_template":"function y = nine_Comp(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 456;\r\ny_correct = 543;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 125;\r\ny_correct = 874;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 56;\r\ny_correct = 43;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 6;\r\ny_correct = 3;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 1456;\r\ny_correct = 8543;\r\nassert(isequal(nine_Comp(x),y_correct))\r\n%%\r\nx = 0;\r\ny_correct = 9;\r\nassert(isequal(nine_Comp(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":352,"test_suite_updated_at":"2015-01-09T12:45:34.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2015-01-09T12:42:55.000Z","updated_at":"2026-02-16T10:13:55.000Z","published_at":"2015-01-09T12:42:55.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the 9's complement of the given 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\u003eAn example of how this works is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://electrical4u.com/9s-complement-and-10s-complement/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eshown here\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2733,"title":"Evil Number","description":"Check if a given natural number is evil or not. \r\n\r\nRead more at \u003chttps://oeis.org/A001969 OEIS\u003e.","description_html":"\u003cp\u003eCheck if a given natural number is evil or not.\u003c/p\u003e\u003cp\u003eRead more at \u003ca href = \"https://oeis.org/A001969\"\u003eOEIS\u003c/a\u003e.\u003c/p\u003e","function_template":"function tf = isevil(n)\r\n  tf = ;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = false;\r\nassert(isequal(isevil(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = true;\r\nassert(isequal(isevil(x),y_correct))\r\n%%\r\nx = [18, 20, 23, 24, 27, 45, 46, 48, 96, 99, 123,];\r\ny_correct = true;\r\nassert(isequal(all(arrayfun(@isevil,x)),y_correct))\r\n%%\r\nx = [14, 16, 19, 37, 38, 55, 56, 59, 62,  79, 82, 91, 93, 94, 97, 98, 117, 118, 121];\r\ny_correct = false;\r\nassert(isequal(any(arrayfun(@isevil,x)),y_correct))\r\n%%\r\nx = 2^randi([5 10])+1;\r\ny_correct = true;\r\nassert(isequal(isevil(x),y_correct))\r\n\r\n%%\r\n% more test cases may be introduced\r\n%%\r\n% DISABLED\r\n% ________'FAIR'_SCORING_SYSTEM______________\r\n%\r\n% This section scores for usage of ans\r\n% and strings, which are common methods \r\n% to reduce cody size of solution.\r\n% Here, strings are threated like vectors.\r\n% Please do not hack it, as this problem\r\n% is not mentioned to be a hacking problem.\r\n% \r\n  try\r\n% disable:\r\nassert(false) \r\n%\r\n  size_old = feval(@evalin,'caller','score');\r\n%\r\n  all_nodes = mtree('isevil.m','-file');\r\n  str_nodes = mtfind(all_nodes,'Kind','STRING');\r\n   eq_nodes = mtfind(all_nodes,'Kind','EQUALS');\r\nprint_nodes = mtfind(all_nodes,'Kind','PRINT');\r\n expr_nodes = mtfind(all_nodes,'Kind','EXPR');\r\n%\r\n       size = count(all_nodes)           ...\r\n              +sum(str_nodes.nodesize-1) ...\r\n              +2*(count(expr_nodes)      ...\r\n                  +count(print_nodes)    ...\r\n                  -count(eq_nodes));\r\n%\r\n  feval(@assignin,'caller','score',size);\r\n%\r\n  fprintf('Size in standard cody scoring is %i.\\n',size_old);\r\n  fprintf('Here it is %i.\\n',size);\r\n  end\r\n%\r\n%_________RESULT_____________________________","published":true,"deleted":false,"likes_count":3,"comments_count":6,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":274,"test_suite_updated_at":"2016-12-26T10:21:47.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-12-07T21:50:01.000Z","updated_at":"2026-03-11T15:15:47.000Z","published_at":"2015-01-19T12:47:58.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\u003eCheck if a given natural number is evil or not.\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\u003eRead more at\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://oeis.org/A001969\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEIS\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":156,"title":"Parasitic numbers","description":"Test whether the first input x is an n-parasitic number: \u003chttp://en.wikipedia.org/wiki/Parasitic_number\u003e. ( _n_ is the second input.)\r\n\r\nExamples:\r\n\r\nparasitic(128205,4) ---\u003e true\r\n\r\nparasitic(179487,4) ---\u003e true\r\n\r\nparasitic(179487,3) ---\u003e false","description_html":"\u003cp\u003eTest whether the first input x is an n-parasitic number: \u003ca href=\"http://en.wikipedia.org/wiki/Parasitic_number\"\u003ehttp://en.wikipedia.org/wiki/Parasitic_number\u003c/a\u003e. ( \u003ci\u003en\u003c/i\u003e is the second input.)\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cp\u003eparasitic(128205,4) ---\u003e true\u003c/p\u003e\u003cp\u003eparasitic(179487,4) ---\u003e true\u003c/p\u003e\u003cp\u003eparasitic(179487,3) ---\u003e false\u003c/p\u003e","function_template":"function y = parasitic(x,n)\r\n  y = x*n;\r\nend","test_suite":"%%\r\nx = 128205;\r\nn = 4\r\ny_correct = true;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 179487;\r\nn = 4;\r\ny_correct = true;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 179487;\r\nn = 3;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142857;\r\nn = 5;\r\ny_correct = true;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142857;\r\nn = 4;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142657;\r\nn = 5;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142857;\r\nn = 4;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 1012658227848;\r\nn = 8;\r\ny_correct = true;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 1012658227848;\r\nn = 4;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 142857;\r\nn = 7;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n%%\r\nx = 12;\r\nn = 2;\r\ny_correct = false;\r\nassert(isequal(parasitic(x,n),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":5,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":315,"test_suite_updated_at":"2016-09-30T20:15:58.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2012-01-29T03:38:27.000Z","updated_at":"2026-03-11T15:14:37.000Z","published_at":"2012-01-29T03:38:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 the first input x is an n-parasitic 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=\\\"http://en.wikipedia.org/wiki/Parasitic_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Parasitic_number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (\u003c/w:t\u003e\u003c/w:r\u003e\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 is the second input.)\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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eparasitic(128205,4) ---\u0026gt; true\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\u003eparasitic(179487,4) ---\u0026gt; true\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\u003eparasitic(179487,3) ---\u0026gt; false\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":139,"title":"Determine if a Given Number is a Triangle Number","description":"*Description:*\r\n\r\nDetermine if the elements of an input array are triangle numbers and return the result as an array with the same dimensions as the input.\r\n\r\n*Example:*\r\n\r\n    Input  = [ 1 2 3 ];\r\n    Output = [ 1 0 1 ];","description_html":"\u003cp\u003e\u003cb\u003eDescription:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eDetermine if the elements of an input array are triangle numbers and return the result as an array with the same dimensions as the input.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cpre\u003e    Input  = [ 1 2 3 ];\r\n    Output = [ 1 0 1 ];\u003c/pre\u003e","function_template":"function y = isTriangleNumber(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1:100;\r\ny_correct = false(1,100);\r\ny_correct([1 3 6 10 15 21 28 36 45 55 66 78 91]) = true;\r\nassert(isequal(isTriangleNumber(x),y_correct))\r\n\r\n%%\r\nx = 1;\r\ny_correct = true;\r\nassert(isequal(isTriangleNumber(x),y_correct))\r\n\r\n%%\r\nx = [4912734125;4912734126];\r\ny_correct = [false;true];\r\nassert(isequal(isTriangleNumber(x),y_correct))","published":true,"deleted":false,"likes_count":8,"comments_count":0,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":398,"test_suite_updated_at":"2012-01-28T09:07:10.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2012-01-28T09:05:06.000Z","updated_at":"2026-02-16T10:37:35.000Z","published_at":"2012-01-28T09:10:17.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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eDescription:\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\u003eDetermine if the elements of an input array are triangle numbers and return the result as an array with the same dimensions as the input.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    Input  = [ 1 2 3 ];\\n    Output = [ 1 0 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":2056,"title":"Is this number Munchhausen?","description":"In this problem, simply return 1 if a supplied number is Munchhausen or 0 if not.\r\nExample\r\n153 is narcissistic but not a Munchhausen number\r\nNOTE: the convention is that 0^0=0","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: 111px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 55.5px; transform-origin: 407px 55.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 250px 8px; transform-origin: 250px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn this problem, simply return 1 if a supplied number is Munchhausen or 0 if not.\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: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\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: 158px 8px; transform-origin: 158px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e153 is narcissistic but not a Munchhausen number\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: 111px 8px; transform-origin: 111px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNOTE: the convention is that 0^0=0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = ismunch(n)\r\n  tf='?';\r\nend","test_suite":"%%\r\nn=1;\r\ny_correct=1;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=0;\r\ny_correct=1;\r\nassert(isequal(ismunch(n),y_correct))\r\n\r\n%%\r\nn=153;\r\ny_correct=0;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=634;\r\ny_correct=0;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=3435;\r\ny_correct=1;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=3534;\r\ny_correct=0;\r\nassert(isequal(ismunch(n),y_correct))\r\n%%\r\nn=438579088;\r\ny_correct=1;\r\nassert(isequal(ismunch(n),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":9,"created_by":17471,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":211,"test_suite_updated_at":"2013-12-15T12:28:07.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-12-15T12:06:13.000Z","updated_at":"2026-02-16T10:17:09.000Z","published_at":"2013-12-15T12:28:07.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\u003eIn this problem, simply return 1 if a supplied number is Munchhausen or 0 if not.\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\u003e153 is narcissistic but not a Munchhausen 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\u003eNOTE: the convention is that 0^0=0\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":1771,"title":"Polygonal numbers","description":"The task of \u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/5 Problem 5\u003e is to calculate triangular numbers. By playing with dots we can produce also square numbers like:\r\n\r\n                                 * * * *\r\n                     * * *       * * * *\r\n           * *       * * *       * * * *\r\n1: *    4: * *    9: * * *   16: * * * *\r\n\r\nor hexagonal numbers:\r\n\r\n                                          * * * *\r\n                                         *       *\r\n                         * * *          * * * *   *\r\n                        *     *        * *     *   *\r\n            * *        * * *   *        * * *   * * \r\n           *   *        *   * *          *   * * *\r\n1: *    6:  * *    15:   * * *       28:  * * * *\r\n\r\n\u0026nbsp\r\n\r\nAccording to those rules we can create \u003chttp://en.wikipedia.org/wiki/Polygonal_number polygonal numbers\u003e for all regular polygons.\r\n\r\n\u0026nbsp\r\n\r\nYour task: given _S_ and _N_ *calculate _N_-th _S_-gonal numbers* _P(S,N)_ \r\n\r\n\u0026nbsp\r\n\r\nExamples:\r\n\r\n# _P(4, 3)_ returns _[9]_    because 3-rd square number is 9,\r\n# _P(3, 1:5)_ returns _[1, 3, 6, 10, 15]_   first 5 triangular numbers,\r\n# _P(3:6, 4)_ returns _[10, 16, 22, 28]_   4-th triangular, square, pentagonal and hexagonal numbers,\r\n# _P([3, 4], [1; 2])_ returns _[1, 1; 3, 4]_.\r\n\r\nsee the test suite for more hints","description_html":"\u003cp\u003eThe task of \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/5\"\u003eProblem 5\u003c/a\u003e is to calculate triangular numbers. By playing with dots we can produce also square numbers like:\u003c/p\u003e\u003cpre\u003e                                 * * * *\r\n                     * * *       * * * *\r\n           * *       * * *       * * * *\r\n1: *    4: * *    9: * * *   16: * * * *\u003c/pre\u003e\u003cp\u003eor hexagonal numbers:\u003c/p\u003e\u003cpre\u003e                                          * * * *\r\n                                         *       *\r\n                         * * *          * * * *   *\r\n                        *     *        * *     *   *\r\n            * *        * * *   *        * * *   * * \r\n           *   *        *   * *          *   * * *\r\n1: *    6:  * *    15:   * * *       28:  * * * *\u003c/pre\u003e\u003cp\u003e\u0026nbsp\u003c/p\u003e\u003cp\u003eAccording to those rules we can create \u003ca href = \"http://en.wikipedia.org/wiki/Polygonal_number\"\u003epolygonal numbers\u003c/a\u003e for all regular polygons.\u003c/p\u003e\u003cp\u003e\u0026nbsp\u003c/p\u003e\u003cp\u003eYour task: given \u003ci\u003eS\u003c/i\u003e and \u003ci\u003eN\u003c/i\u003e \u003cb\u003ecalculate \u003ci\u003eN\u003c/i\u003e-th \u003ci\u003eS\u003c/i\u003e-gonal numbers\u003c/b\u003e \u003ci\u003eP(S,N)\u003c/i\u003e\u003c/p\u003e\u003cp\u003e\u0026nbsp\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003col\u003e\u003cli\u003e\u003ci\u003eP(4, 3)\u003c/i\u003e returns \u003ci\u003e[9]\u003c/i\u003e    because 3-rd square number is 9,\u003c/li\u003e\u003cli\u003e\u003ci\u003eP(3, 1:5)\u003c/i\u003e returns \u003ci\u003e[1, 3, 6, 10, 15]\u003c/i\u003e   first 5 triangular numbers,\u003c/li\u003e\u003cli\u003e\u003ci\u003eP(3:6, 4)\u003c/i\u003e returns \u003ci\u003e[10, 16, 22, 28]\u003c/i\u003e   4-th triangular, square, pentagonal and hexagonal numbers,\u003c/li\u003e\u003cli\u003e\u003ci\u003eP([3, 4], [1; 2])\u003c/i\u003e returns \u003ci\u003e[1, 1; 3, 4]\u003c/i\u003e.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003esee the test suite for more hints\u003c/p\u003e","function_template":"function y = P(s,n)\r\n  y = s*n;\r\nend","test_suite":"%%\r\nassert(P(4,3)==9)\r\n%%\r\ns=3;\r\nn=1:5;\r\ny_correct=[1 3 6 10 15];\r\nassert(isequal(P(s,n),y_correct))\r\n%%\r\ns=3:6;\r\nn=4;\r\nY_correct=[10 16 22 28];\r\nassert(isequal(P(s,n),Y_correct))\r\n%%\r\ns=randi([3 1000],1,10);\r\nn=1;\r\ny_correct=ones(1,10);\r\nassert(isequal(P(s,n),y_correct))\r\n%%\r\ns=randi(1000,1,10)+2;\r\nn=5;\r\ny_correct=10*s-15;\r\nassert(isequal(P(s,n),y_correct))\r\n%%\r\ns=[5 6 7]';\r\nn=[2 8 9];\r\ny_correct=[5 92 117;6 120 153;7 148 189];\r\nassert(isequal(P(s,n),y_correct))\r\n%%\r\n% for M.Z.\r\ns=[5 6 7]';\r\nn=[2 8 9];\r\ny_correct=[5 92 117;6 120 153;7 148 189];\r\nassert(isequal(P(flipud(s),n),flipud(y_correct)))\r\n%%\r\ns=randi([3,1000]);\r\nn=randi([3,1000]);\r\nassert(P(s+1,n+1)-P(s,n+1)==P(3,n))\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":4,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":138,"test_suite_updated_at":"2016-10-15T05:56:15.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2013-08-02T13:16:29.000Z","updated_at":"2026-02-16T10:32:51.000Z","published_at":"2013-08-02T23:34:24.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\u003eThe task of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/cody/problems/5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is to calculate triangular numbers. By playing with dots we can produce also square numbers like:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[                                 * * * *\\n                     * * *       * * * *\\n           * *       * * *       * * * *\\n1: *    4: * *    9: * * *   16: * * * *]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eor hexagonal numbers:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[                                          * * * *\\n                                         *       *\\n                         * * *          * * * *   *\\n                        *     *        * *     *   *\\n            * *        * * *   *        * * *   * * \\n           *   *        *   * *          *   * * *\\n1: *    6:  * *    15:   * * *       28:  * * * *]]\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\u003e\u0026amp;nbsp\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\u003eAccording to those rules we can create\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Polygonal_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003epolygonal numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for all regular polygons.\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\u0026amp;nbsp\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: given\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\u003eS\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw: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 \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecalculate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e-th\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eS\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e-gonal numbers\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\u003eP(S,N)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026amp;nbsp\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP(4, 3)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns\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\u003e[9]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e because 3-rd square number is 9,\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP(3, 1:5)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns\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\u003e[1, 3, 6, 10, 15]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e first 5 triangular numbers,\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP(3:6, 4)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns\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\u003e[10, 16, 22, 28]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 4-th triangular, square, pentagonal and hexagonal numbers,\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP([3, 4], [1; 2])\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns\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\u003e[1, 1; 3, 4]\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\u003esee the test suite for more hints\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":2690,"title":"Armstrong Number","description":"Determine whether the given input n-digit number is Armstrong Number or not.\r\nReturn True if it is an Armstrong Number. An n-Digit Armstrong number is an integer such that the sum of the power n of its digit is equal to the number itself.\r\nFor Example:\r\n 371 = 3^3 + 7^3 + 1^3  or \r\n 1741725 = 1^7 + 7^7 + 4^7 + 1^7 + 7^7 + 2^7 + 5^7","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: 152.867px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 76.4333px; transform-origin: 407px 76.4333px; 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: 246px 8px; transform-origin: 246px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eDetermine whether the given input n-digit number is Armstrong Number or not.\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: 378px 8px; transform-origin: 378px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn True if it is an Armstrong Number. An n-Digit Armstrong number is an integer such that the sum of the power n of its digit is equal to the number itself.\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: 41.5px 8px; transform-origin: 41.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor Example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 108px 8.5px; tab-size: 4; transform-origin: 108px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e 371 = 3^3 + 7^3 + 1^3  or \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 200px 8.5px; tab-size: 4; transform-origin: 200px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e 1741725 = 1^7 + 7^7 + 4^7 + 1^7 + 7^7 + 2^7 + 5^7\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = Armstrong(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 9;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 371;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 24;\r\ny_correct = 0;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 407;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 1634;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 68955;\r\ny_correct = 0;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 11;\r\ny_correct = 0;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 548834;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n%%\r\nx = 1741725;\r\ny_correct = 1;\r\nassert(isequal(Armstrong(x),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":8,"comments_count":2,"created_by":32100,"edited_by":223089,"edited_at":"2022-11-19T15:34:07.000Z","deleted_by":null,"deleted_at":null,"solvers_count":356,"test_suite_updated_at":"2022-11-19T15:34:07.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2014-11-25T09:16:05.000Z","updated_at":"2026-02-16T10:19:41.000Z","published_at":"2014-11-25T09:16:36.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\u003eDetermine whether the given input n-digit number is Armstrong Number or not.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn True if it is an Armstrong Number. An n-Digit Armstrong number is an integer such that the sum of the power n of its digit is equal to the number itself.\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:\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[ 371 = 3^3 + 7^3 + 1^3  or \\n 1741725 = 1^7 + 7^7 + 4^7 + 1^7 + 7^7 + 2^7 + 5^7]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2593,"title":"Polite numbers. N-th polite number.","description":"A polite number is an integer that sums of at least two consecutive positive integers.\r\n\r\nFor example _7 = 3+4_ so 7 is a polite number.\r\n\r\nGiven _N_ return N-th polite number.\r\n\r\nSee also \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2595 2595\u003e","description_html":"\u003cp\u003eA polite number is an integer that sums of at least two consecutive positive integers.\u003c/p\u003e\u003cp\u003eFor example \u003ci\u003e7 = 3+4\u003c/i\u003e so 7 is a polite number.\u003c/p\u003e\u003cp\u003eGiven \u003ci\u003eN\u003c/i\u003e return N-th polite number.\u003c/p\u003e\u003cp\u003eSee also \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2595\"\u003e2595\u003c/a\u003e\u003c/p\u003e","function_template":"function polite = Nth_polite(n)\r\n  polite = n;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 3;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 5;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 4;\r\ny_correct = 7;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 9;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 7;\r\ny_correct = 11;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 11;\r\ny_correct = 15;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 12;\r\ny_correct = 17;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 14;\r\ny_correct = 19;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 19;\r\ny_correct = 24;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 21;\r\ny_correct = 26;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 27;\r\ny_correct = 33;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 64;\r\ny_correct = 71;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 1e6;\r\ny_correct = x+20;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 1e7;\r\ny_correct = x+24;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n%%\r\nx = 999999999;\r\ny_correct = x+30;\r\nassert(isequal(Nth_polite(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":166,"test_suite_updated_at":"2014-09-17T10:56:47.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2014-09-16T22:44:09.000Z","updated_at":"2026-02-16T10:31:08.000Z","published_at":"2014-09-17T10:56:47.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA polite number is an integer that sums of at least two consecutive positive integers.\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\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\u003e7 = 3+4\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e so 7 is a polite 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\u003eGiven\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 return N-th polite 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\u003eSee also\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2595\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e2595\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":2734,"title":"N-th Odious","description":"Given index n return n-th \u003chttps://oeis.org/A000069 odious number\u003e.","description_html":"\u003cp\u003eGiven index n return n-th \u003ca href = \"https://oeis.org/A000069\"\u003eodious number\u003c/a\u003e.\u003c/p\u003e","function_template":"function y = nthodious(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 2;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = 4;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 9;\r\ny_correct = 16;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 17;\r\ny_correct = 32;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 33;\r\ny_correct = 64;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 65;\r\ny_correct = 128;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 3387;\r\ny_correct = 6772;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 22;\r\ny_correct = 42;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\nx = 1e5;\r\ny_correct = 2e5-1;\r\nassert(isequal(nthodious(x),y_correct))\r\n%%\r\n% more test cases may be introduced\r\n%%\r\n% DISABLED\r\n% ________'FAIR'_SCORING_SYSTEM______________\r\n%\r\n% This section scores for usage of ans\r\n% and strings, which are common methods \r\n% to reduce cody size of solution.\r\n% Here, strings are threated like vectors.\r\n% Please do not hack it, as this problem\r\n% is not mentioned to be a hacking problem.\r\n% \r\n  try\r\nassert(false)\r\n% \r\n  size_old = feval(@evalin,'caller','score');\r\n%\r\n  all_nodes = mtree('nthodious.m','-file');\r\n  str_nodes = mtfind(all_nodes,'Kind','STRING');\r\n   eq_nodes = mtfind(all_nodes,'Kind','EQUALS');\r\nprint_nodes = mtfind(all_nodes,'Kind','PRINT');\r\n expr_nodes = mtfind(all_nodes,'Kind','EXPR');\r\n%\r\n       size = count(all_nodes)           ...\r\n              +sum(str_nodes.nodesize-1) ...\r\n              +2*(count(expr_nodes)      ...\r\n                  +count(print_nodes)    ...\r\n                  -count(eq_nodes));\r\n%\r\n  feval(@assignin,'caller','score',size);\r\n%\r\n  fprintf('Size in standard cody scoring is %i.\\n',size_old);\r\n  fprintf('Here it is %i.\\n',size);\r\n  end\r\n%\r\n%_________RESULT_____________________________\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":182,"test_suite_updated_at":"2015-01-19T23:07:07.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-12-07T21:50:54.000Z","updated_at":"2026-02-16T10:22:49.000Z","published_at":"2015-01-19T13:39:11.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 index n return n-th\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://oeis.org/A000069\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eodious number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":166,"title":"Kaprekar numbers","description":"Test if the input is a Kaprekar number: \u003chttp://mathworld.wolfram.com/KaprekarNumber.html\u003e. Return a logical true or false.\r\n\r\n\r\n","description_html":"\u003cp\u003eTest if the input is a Kaprekar number: \u003ca href=\"http://mathworld.wolfram.com/KaprekarNumber.html\"\u003ehttp://mathworld.wolfram.com/KaprekarNumber.html\u003c/a\u003e. Return a logical true or false.\u003c/p\u003e","function_template":"function tf = kap(x)\r\n  tf = maybe;\r\nend","test_suite":"%%\r\nx = 16;\r\ntf_correct = false;\r\nassert(isequal(kap(x),tf_correct))\r\n\r\n%%\r\nx = 704;\r\ntf_correct = false;\r\nassert(isequal(kap(x),tf_correct))\r\n\r\n%%\r\nx = 9\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 45\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 55\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 99\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 297\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 703\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 999\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 2223\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 2728\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 4950\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 5050\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 7272\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 7777\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 9999\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 17344\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 22222\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 77778\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 82656\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 95121\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 99999\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 142857\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 148149\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 181819\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 187110\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 208495\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 318682\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 329967\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 351352\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 356643\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 390313\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 461539\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 466830\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 499500\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 500500\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 533170\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 538461\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 609687\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 643357\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 648648\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 670033\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 681318\r\ntf_correct = true\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 681319\r\ntf_correct = false\r\nassert(isequal(kap(x),tf_correct))\r\n%%\r\nx = 681320\r\ntf_correct = false\r\nassert(isequal(kap(x),tf_correct))","published":true,"deleted":false,"likes_count":5,"comments_count":2,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":294,"test_suite_updated_at":"2016-06-14T14:57:02.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2012-01-29T16:05:57.000Z","updated_at":"2026-02-16T10:34:39.000Z","published_at":"2012-01-29T16:05:57.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 if the input is a Kaprekar 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=\\\"http://mathworld.wolfram.com/KaprekarNumber.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://mathworld.wolfram.com/KaprekarNumber.html\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Return a logical true or false.\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":2248,"title":"Bell Number calculator","description":"Calculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the Wikipedia entry for Bell Number.\r\nExample\r\n Belln(8) = [1 1 2 5 15 52 203 877 4140]","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: 102.433px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 51.2167px; transform-origin: 407px 51.2167px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 374px 8px; transform-origin: 374px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWikipedia entry for Bell Number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 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: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 160px 8.5px; transform-origin: 160px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Belln(8) = [1 1 2 5 15 52 203 877 4140]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = Belln(n)\r\n  y = [1:x];\r\nend","test_suite":"%%\r\nn = 0;\r\ny_correct = 1;\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 5;\r\ny_correct = [1 1 2 5 15 52];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 10;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 13;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975 678570 4213597 27644437];\r\nassert(isequal(Belln(n),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":23893,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":191,"test_suite_updated_at":"2021-06-16T09:39:43.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-03-14T09:59:39.000Z","updated_at":"2026-02-16T10:15:53.000Z","published_at":"2014-03-14T10:09:41.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\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia entry for Bell Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[ Belln(8) = [1 1 2 5 15 52 203 877 4140]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1472,"title":"nth Rational Number","description":"Return the nth rational number.\r\nThis is the inverse to Problem 1471. Index of a Rational number\r\nThe first ten positive rational numbers under the enumeration using cantors diagonalization argument are 1/1, 2/1, 1/2, 3/1, 2/2, 1/3, 4/1, 3/2, 2/3, 1/4.\r\nFind the index of a positive rational number enumerated in this manner, i.e. the 6th rational number is 1/3.\r\nProblem 2) Prev: 1471 Next: 1477","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: 162px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 81px; transform-origin: 407px 81px; 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: 98.5px 8px; transform-origin: 98.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn the nth rational number.\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: 93.5px 8px; transform-origin: 93.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis is the inverse to Problem\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e1471\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 88.5px 8px; transform-origin: 88.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Index of a Rational number\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: 375px 8px; transform-origin: 375px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe first ten positive rational numbers under the enumeration using cantors diagonalization argument are 1/1, 2/1, 1/2, 3/1, 2/2, 1/3, 4/1, 3/2, 2/3, 1/4.\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: 332px 8px; transform-origin: 332px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFind the index of a positive rational number enumerated in this manner, i.e. the 6th rational number is 1/3.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 53px 8px; transform-origin: 53px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eProblem 2) Prev:\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e1471\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 17.5px 8px; transform-origin: 17.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e Next:\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e1477\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function out = cantor_index2rational(x)\r\np=1; q=1;\r\nout=[p q]\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = [1 1];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = [2 1];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 6;\r\ny_correct = [1 3];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 385;\r\ny_correct = [22 7];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx=108924;\r\ny_correct = [355 113];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 206;\r\ny_correct = [5 16];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 2060;\r\ny_correct = [21 44];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 20604;\r\ny_correct = [103 101];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 20704;\r\ny_correct = [3 201];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 205704;\r\ny_correct = [58 584];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 2085704;\r\ny_correct = [200 1843];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 20851704;\r\ny_correct = [4408 2051];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n%%\r\nx = 290851704;\r\ny_correct = [23437 683];\r\nassert(isequal(cantor_index2rational(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":11275,"edited_by":223089,"edited_at":"2022-11-29T16:44:48.000Z","deleted_by":null,"deleted_at":null,"solvers_count":172,"test_suite_updated_at":"2022-11-29T16:44:48.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-04-30T02:37:22.000Z","updated_at":"2026-02-16T10:20:29.000Z","published_at":"2013-04-30T02:37:22.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\u003eReturn the nth rational 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\u003eThis is the inverse to Problem\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e1471\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Index of a Rational 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\u003eThe first ten positive rational numbers under the enumeration using cantors diagonalization argument are 1/1, 2/1, 1/2, 3/1, 2/2, 1/3, 4/1, 3/2, 2/3, 1/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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the index of a positive rational number enumerated in this manner, i.e. the 6th rational number is 1/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\u003eProblem 2) Prev:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e1471\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e Next:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e1477\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2595,"title":"Polite numbers. Politeness.","description":"A polite number is an integer that sums of two or more consecutive positive integers.\r\nPoliteness of a positive integer is a number of nontrivial ways to write n as a sum of two or more consecutive positive integers.\r\n\r\nFor example _9 = 4+5 = 2+3+4_  and politeness of 9 is 2.\r\n\r\nGiven _N_ return politeness of _N_.\r\n\r\nSee also \u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/2593 2593\u003e","description_html":"\u003cp\u003eA polite number is an integer that sums of two or more consecutive positive integers.\r\nPoliteness of a positive integer is a number of nontrivial ways to write n as a sum of two or more consecutive positive integers.\u003c/p\u003e\u003cp\u003eFor example \u003ci\u003e9 = 4+5 = 2+3+4\u003c/i\u003e  and politeness of 9 is 2.\u003c/p\u003e\u003cp\u003eGiven \u003ci\u003eN\u003c/i\u003e return politeness of \u003ci\u003eN\u003c/i\u003e.\u003c/p\u003e\u003cp\u003eSee also \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/2593\"\u003e2593\u003c/a\u003e\u003c/p\u003e","function_template":"function P = politeness(N)\r\n  P=N;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 0;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = 1;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 7;\r\ny_correct = 1;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 9;\r\ny_correct = 2;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 15;\r\ny_correct = 3;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 18;\r\ny_correct = 2;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 21;\r\ny_correct = 3;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 1024;\r\ny_correct = 0;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 1025;\r\ny_correct = 5;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 25215;\r\ny_correct = 11;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 62;\r\ny_correct = 1;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 63;\r\ny_correct = 5;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nx = 65;\r\ny_correct = 3;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\n% anti-lookup \u0026 clue\r\nnums=primes(200);\r\npattern=[1 nums([false ~randi([0 25],1,45)])];\r\nx=prod(pattern)*2^randi([0 5]);\r\ny_correct=2^numel(pattern)/2-1;\r\nassert(isequal(politeness(x),y_correct))\r\n%%\r\nfor k=randi(2e4,1,20)\r\n  assert(isequal(politeness(k*(k-1))+1,(politeness(k)+1)*(politeness(k-1)+1)))\r\nend","published":true,"deleted":false,"likes_count":8,"comments_count":6,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":186,"test_suite_updated_at":"2014-09-17T15:38:21.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2014-09-16T22:47:12.000Z","updated_at":"2026-02-16T10:30:04.000Z","published_at":"2014-09-17T10:56: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\u003eA polite number is an integer that sums of two or more consecutive positive integers. Politeness of a positive integer is a number of nontrivial ways to write n as a sum of two or more consecutive positive integers.\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\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\u003e9 = 4+5 = 2+3+4\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and politeness of 9 is 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\u003eGiven\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 return politeness of\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.\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 also\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/cody/problems/2593\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e2593\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":1925,"title":"Smith numbers","description":"Return true if the input is a Smith number in base ten. Otherwise, return false. Read about Smith numbers at http://en.wikipedia.org/wiki/Smith_number.\r\nA Smith number must be positive and have more than one factor.","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: 72px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.5px 36px; transform-origin: 406.5px 36px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 383.5px 21px; text-align: left; transform-origin: 383.5px 21px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 348.958px 7.81667px; transform-origin: 348.958px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn true if the input is a Smith number in base ten. Otherwise, return false. Read about Smith numbers at\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: 2.23333px 7.81667px; transform-origin: 2.23333px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Smith_number\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ehttp://en.wikipedia.org/wiki/Smith_number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2.23333px 7.81667px; transform-origin: 2.23333px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 383.5px 10.5px; text-align: left; transform-origin: 383.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 208.258px 7.81667px; transform-origin: 208.258px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA Smith number must be positive and have more than one factor.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = isSmith(x)\r\n  tf = false;\r\nend","test_suite":"%%\r\nx = 4;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 265;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 588;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 1086;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 4937775;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 5;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 1000;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 94.1;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 202.689;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = pi;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = -4;\r\ntf_correct = false;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n%%\r\nx = 11^2;\r\ntf_correct = true;\r\nassert(isequal(isSmith(x),tf_correct ))\r\n\r\n\r\n%%\r\nx = 9^3;\r\ny = [-1 0 1];\r\ntf=true;\r\nfor k=1:numel(x)\r\n    tf=tf\u0026\u0026isequal(isSmith(x(k)+y(k)), y(k)\u003c1)\r\nend\r\nassert(isequal(tf, true))","published":true,"deleted":false,"likes_count":5,"comments_count":0,"created_by":10139,"edited_by":223089,"edited_at":"2024-08-04T06:35:24.000Z","deleted_by":null,"deleted_at":null,"solvers_count":776,"test_suite_updated_at":"2024-08-04T06:35:24.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2013-10-09T12:32:02.000Z","updated_at":"2026-01-12T18:27:18.000Z","published_at":"2013-10-09T12:32:07.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\u003eReturn true if the input is a Smith number in base ten. Otherwise, return false. Read about Smith numbers at\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/Smith_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Smith_number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA Smith number must be positive and have more than one factor.\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\"}]}"}],"term":"difficulty_rating_bin:medium group:\"Magic Numbers\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"difficulty_rating_bin:medium group:\"Magic Numbers\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"difficulty_rating_bin":[["difficulty_rating_bin:medium","","","medium",""]],"group":[["group:\"Magic Numbers\"","","\"","Magic Numbers","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f5349171cd8\u003e":["Magic Numbers"],"#\u003cMathWorks::Search::Field:0x00007f5349171c38\u003e":["medium"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007f5349171238\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f5349171f58\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f5349171eb8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f5349171e18\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f5349171d78\u003e":"difficulty_rating_bin:medium group:\"Magic Numbers\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f5349171d78\u003e":"difficulty_rating_bin:medium group:\"Magic Numbers\""},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f5349171cd8\u003e":["Magic Numbers"],"#\u003cMathWorks::Search::Field:0x00007f5349171c38\u003e":["medium"]}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"difficulty_rating_bin:medium group:\"Magic Numbers\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"difficulty_rating_bin":[["difficulty_rating_bin:medium","","","medium",""]],"group":[["group:\"Magic Numbers\"","","\"","Magic Numbers","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f5349171cd8\u003e":["Magic Numbers"],"#\u003cMathWorks::Search::Field:0x00007f5349171c38\u003e":["medium"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007f5349171238\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f5349171f58\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f5349171eb8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f5349171e18\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f5349171d78\u003e":"difficulty_rating_bin:medium group:\"Magic Numbers\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f5349171d78\u003e":"difficulty_rating_bin:medium group:\"Magic Numbers\""},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f5349171cd8\u003e":["Magic Numbers"],"#\u003cMathWorks::Search::Field:0x00007f5349171c38\u003e":["medium"]}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":1997,"difficulty_rating":"easy-medium"},{"id":2061,"difficulty_rating":"easy-medium"},{"id":2819,"difficulty_rating":"easy-medium"},{"id":2733,"difficulty_rating":"easy-medium"},{"id":156,"difficulty_rating":"easy-medium"},{"id":139,"difficulty_rating":"easy-medium"},{"id":2056,"difficulty_rating":"easy-medium"},{"id":1771,"difficulty_rating":"easy-medium"},{"id":2690,"difficulty_rating":"easy-medium"},{"id":2593,"difficulty_rating":"easy-medium"},{"id":2734,"difficulty_rating":"easy-medium"},{"id":166,"difficulty_rating":"easy-medium"},{"id":2248,"difficulty_rating":"easy-medium"},{"id":1472,"difficulty_rating":"medium"},{"id":2595,"difficulty_rating":"medium"},{"id":1925,"difficulty_rating":"medium"}]}}