{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-05-26T00:16:20.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-05-26T00: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":1909,"title":"Two fractions, one sum","description":"Given a positive number x, write a MATLAB script that will tell you how many ways that the reciprocal of that number can be written as a sum of two reciprocals of integers.  For example, 1/10 can be written as:\r\n\r\n* 1/11 + 1/110\r\n* 1/12 + 1/60\r\n* 1/14 + 1/35\r\n* 1/15 + 1/30\r\n* 1/20 + 1/20\r\n\r\nThe order of the fractions does not matter, so 1/11+1/110 is the same as 1/110+1/11.  Therefore, two_fractions(10)=5.  You do not need to output the fraction pairs themselves, only the total number of sums.  Good luck!","description_html":"\u003cp\u003eGiven a positive number x, write a MATLAB script that will tell you how many ways that the reciprocal of that number can be written as a sum of two reciprocals of integers.  For example, 1/10 can be written as:\u003c/p\u003e\u003cul\u003e\u003cli\u003e1/11 + 1/110\u003c/li\u003e\u003cli\u003e1/12 + 1/60\u003c/li\u003e\u003cli\u003e1/14 + 1/35\u003c/li\u003e\u003cli\u003e1/15 + 1/30\u003c/li\u003e\u003cli\u003e1/20 + 1/20\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe order of the fractions does not matter, so 1/11+1/110 is the same as 1/110+1/11.  Therefore, two_fractions(10)=5.  You do not need to output the fraction pairs themselves, only the total number of sums.  Good luck!\u003c/p\u003e","function_template":"function y = two_fractions(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1; y_correct = 1; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 10; y_correct = 5; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 120; y_correct = 32; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 9240; y_correct = 284; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 510510; y_correct = 1094; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 223092869; y_correct = 14; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 223092870; y_correct = 9842; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 223092871; y_correct = 5; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nt7=two_fractions(10^7);\r\nt8=two_fractions(10^8);\r\nt9=two_fractions(10^9);\r\n\r\nx1=str2num(sprintf('%g',t7,t8,t9))\r\nassert(isprime(x1));\r\nassert(x1\u003e1e8);\r\n\r\nx2=str2num(sprintf('%g',t9,t8,t7))\r\nfx2=factor(x2);\r\nassert(numel(fx2)==2);\r\nassert(all(fx2\u003e10000));\r\nassert(isequal(two_fractions(t7+t8+t9),2));\r\n\r\nassert(isequal(two_fractions(x1+x2),two_fractions(x2)));\r\n%%\r\ntic\r\nsatf=sum(arrayfun(@(x) two_fractions(x),1:10000));\r\nassert(isequal(satf,186991))\r\ntoc","published":true,"deleted":false,"likes_count":5,"comments_count":5,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":28,"test_suite_updated_at":"2018-08-22T13:45:50.000Z","rescore_all_solutions":true,"group_id":38,"created_at":"2013-10-02T20:00:41.000Z","updated_at":"2026-05-27T13:41:11.000Z","published_at":"2013-10-02T20:00:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a positive number x, write a MATLAB script that will tell you how many ways that the reciprocal of that number can be written as a sum of two reciprocals of integers. For example, 1/10 can be written as:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/11 + 1/110\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/12 + 1/60\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/14 + 1/35\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/15 + 1/30\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/20 + 1/20\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe order of the fractions does not matter, so 1/11+1/110 is the same as 1/110+1/11. Therefore, two_fractions(10)=5. You do not need to output the fraction pairs themselves, only the total number of sums. Good luck!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"problems":[{"id":1909,"title":"Two fractions, one sum","description":"Given a positive number x, write a MATLAB script that will tell you how many ways that the reciprocal of that number can be written as a sum of two reciprocals of integers.  For example, 1/10 can be written as:\r\n\r\n* 1/11 + 1/110\r\n* 1/12 + 1/60\r\n* 1/14 + 1/35\r\n* 1/15 + 1/30\r\n* 1/20 + 1/20\r\n\r\nThe order of the fractions does not matter, so 1/11+1/110 is the same as 1/110+1/11.  Therefore, two_fractions(10)=5.  You do not need to output the fraction pairs themselves, only the total number of sums.  Good luck!","description_html":"\u003cp\u003eGiven a positive number x, write a MATLAB script that will tell you how many ways that the reciprocal of that number can be written as a sum of two reciprocals of integers.  For example, 1/10 can be written as:\u003c/p\u003e\u003cul\u003e\u003cli\u003e1/11 + 1/110\u003c/li\u003e\u003cli\u003e1/12 + 1/60\u003c/li\u003e\u003cli\u003e1/14 + 1/35\u003c/li\u003e\u003cli\u003e1/15 + 1/30\u003c/li\u003e\u003cli\u003e1/20 + 1/20\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe order of the fractions does not matter, so 1/11+1/110 is the same as 1/110+1/11.  Therefore, two_fractions(10)=5.  You do not need to output the fraction pairs themselves, only the total number of sums.  Good luck!\u003c/p\u003e","function_template":"function y = two_fractions(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1; y_correct = 1; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 10; y_correct = 5; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 120; y_correct = 32; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 9240; y_correct = 284; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 510510; y_correct = 1094; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 223092869; y_correct = 14; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 223092870; y_correct = 9842; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nx = 223092871; y_correct = 5; assert(isequal(two_fractions(x),y_correct))\r\n%%\r\nt7=two_fractions(10^7);\r\nt8=two_fractions(10^8);\r\nt9=two_fractions(10^9);\r\n\r\nx1=str2num(sprintf('%g',t7,t8,t9))\r\nassert(isprime(x1));\r\nassert(x1\u003e1e8);\r\n\r\nx2=str2num(sprintf('%g',t9,t8,t7))\r\nfx2=factor(x2);\r\nassert(numel(fx2)==2);\r\nassert(all(fx2\u003e10000));\r\nassert(isequal(two_fractions(t7+t8+t9),2));\r\n\r\nassert(isequal(two_fractions(x1+x2),two_fractions(x2)));\r\n%%\r\ntic\r\nsatf=sum(arrayfun(@(x) two_fractions(x),1:10000));\r\nassert(isequal(satf,186991))\r\ntoc","published":true,"deleted":false,"likes_count":5,"comments_count":5,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":28,"test_suite_updated_at":"2018-08-22T13:45:50.000Z","rescore_all_solutions":true,"group_id":38,"created_at":"2013-10-02T20:00:41.000Z","updated_at":"2026-05-27T13:41:11.000Z","published_at":"2013-10-02T20:00:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a positive number x, write a MATLAB script that will tell you how many ways that the reciprocal of that number can be written as a sum of two reciprocals of integers. For example, 1/10 can be written as:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/11 + 1/110\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/12 + 1/60\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/14 + 1/35\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/15 + 1/30\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/20 + 1/20\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe order of the fractions does not matter, so 1/11+1/110 is the same as 1/110+1/11. Therefore, two_fractions(10)=5. You do not need to output the fraction pairs themselves, only the total number of sums. Good luck!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"errors":[],"facets":[[],[{"value":"medium","count":1,"selected":false}]],"term":"tag:\"reciprocals\"","page":1,"per_page":50,"sort":"map(difficulty_value,0,0,999) asc"}}