{"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":42509,"title":"Divisible by n, Truncated-number Divisors","description":"Some divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\r\n\r\n* 25: The last two digits must be divisible by 25.\r\n* 32: The last five digits must be divisible by 32.\r\n* 50: The last two digits must be 00 or 50.\r\n* 64: The last six digits must be divisible by 64.\r\n* 75: The number must be divisible by 3 (can be done by a \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3 simple sum\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25). \r\n* 100: The last two digits must be 00.\r\n* 125: The last three digits must be divisible by 125.\r\n* 128: The last seven digits must be divisible by 128.\r\n* 256: The last eight digits must be divisible by 256.\r\n* 512: The last nine digits must be divisible by 512.\r\n\r\nThe only restriction that remains is Java.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200 Divisible by n, prime divisors from 20 to 200\u003e. Next problem \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors Divisible by n, Composite Divisors\u003e.","description_html":"\u003cp\u003eSome divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\u003c/p\u003e\u003cul\u003e\u003cli\u003e25: The last two digits must be divisible by 25.\u003c/li\u003e\u003cli\u003e32: The last five digits must be divisible by 32.\u003c/li\u003e\u003cli\u003e50: The last two digits must be 00 or 50.\u003c/li\u003e\u003cli\u003e64: The last six digits must be divisible by 64.\u003c/li\u003e\u003cli\u003e75: The number must be divisible by 3 (can be done by a \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3\"\u003esimple sum\u003c/a\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25).\u003c/li\u003e\u003cli\u003e100: The last two digits must be 00.\u003c/li\u003e\u003cli\u003e125: The last three digits must be divisible by 125.\u003c/li\u003e\u003cli\u003e128: The last seven digits must be divisible by 128.\u003c/li\u003e\u003cli\u003e256: The last eight digits must be divisible by 256.\u003c/li\u003e\u003cli\u003e512: The last nine digits must be divisible by 512.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe only restriction that remains is Java.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\"\u003eDivisible by n, prime divisors from 20 to 200\u003c/a\u003e. Next problem \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors\"\u003eDivisible by n, Composite Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = truncated_number_divisors(n,n_str)\r\n\r\ntf = 1;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('truncated_number_divisors.m');\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 25;\r\nn_str = '123456789025';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 25;\r\nn_str = '1234567890250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 25;\r\nn_str = '1234567890250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 32;\r\nn_str = '213546116579874651316984601654958847098406516051320150408460840649084790870510201378465465046760406541654604601561065140637860373703970644065166540616510650165409684098049804165016510320540540645106056501650165709804650860466840650156106165028224';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 32;\r\nn_str = '213546116579874651316984601654958847098406516051320150408460840649084790870510201378465465046760406541654604601561065140637860373703970644065166540616510650165409684098049804165016510320540540645106056501650165709804650860466840650156106165028227';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '15668045014654987098045406540500';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '50440984098480149540561065106510516501615001';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '50440984098480149540561065106510516501615001897241387234587503198417059813645097867234985672307485679813709582304957234897659832746098514949188412929894824924949334949777378994191995216173718811313515141418186186382171646871681436817897678350';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404996';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489216';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489217';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 75;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499175';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 75;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499275';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992750';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992700';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499200';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499200125';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489216';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111114892375';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 128;\r\nn_str = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111148923751048576';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 128;\r\nn_str = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111148923751048578';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 256;\r\nn_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678904049917516777216';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 256;\r\nn_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678904049917516777210';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000134217728';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000536870912';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000536870914';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-17T21:32:54.000Z","updated_at":"2026-01-11T10:42:54.000Z","published_at":"2015-08-17T21:32:54.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSome divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e25: The last two digits must be divisible by 25.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e32: The last five digits must be divisible by 32.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e50: The last two digits must be 00 or 50.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e64: The last six digits must be divisible by 64.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e75: The number must be divisible by 3 (can be done by a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esimple sum\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e100: The last two digits must be 00.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e125: The last three digits must be divisible by 125.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e128: The last seven digits must be divisible by 128.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e256: The last eight digits must be divisible by 256.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e512: The last nine digits must be divisible by 512.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe only restriction that remains is Java.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors from 20 to 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Composite Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42454,"title":"Divisible by n, prime divisors (including powers)","description":"For this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\r\n\r\n  n = 1:10;\r\n  n_p = [2 3 4 5 7 8 9];\r\n\r\nSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e.","description_html":"\u003cp\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1:10;\r\nn_p = [2 3 4 5 7 8 9];\r\n\u003c/pre\u003e\u003cp\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_p] = prime_divisors_incl_powers(n)\r\n\r\nn_p = 1;\r\n\r\nend","test_suite":"%%\r\nn = 1:10;\r\nn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = [2:7 12:17 10 42:55 11 19:29];\r\nn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1:100;\r\nn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 41:59;\r\nn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 100:200;\r\nn_p = [101 103 107 109 113 121 125 127 128 131 137 139 149 151 157 163 167 169 173 179 181 191 193 197 199]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1000:1111;\r\nn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:10;\r\n\t\tn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 3\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\n\tcase 3\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = 1000:1111;\r\n\t\tn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":95,"test_suite_updated_at":"2017-03-20T19:03:08.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:55:28.000Z","updated_at":"2026-01-11T12:28:45.000Z","published_at":"2015-07-09T01:55:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[n = 1:10;\\nn_p = [2 3 4 5 7 8 9];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42510,"title":"Divisible by n, Composite Divisors","description":"Pursuant to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\r\n\r\nAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\r\n\r\nThe only restriction that remains is Java.\r\n\r\n* Divisible by 2: if the last digit is divisible by 2.\r\n* Divisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\r\n* Divisible by 4: if the last two digits are divisible by 4.\r\n* Divisible by 5: if the last digit is a 0 or 5.\r\n* Divisible by 8: if the last three digits are divisible by 8.\r\n* Divisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\r\n* Divisible by 10: if the last digit is zero.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors Divisible by n, Truncated-number Divisors\u003e.","description_html":"\u003cp\u003ePursuant to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\u003c/p\u003e\u003cp\u003eAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\u003c/p\u003e\u003cp\u003eThe only restriction that remains is Java.\u003c/p\u003e\u003cul\u003e\u003cli\u003eDivisible by 2: if the last digit is divisible by 2.\u003c/li\u003e\u003cli\u003eDivisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/li\u003e\u003cli\u003eDivisible by 4: if the last two digits are divisible by 4.\u003c/li\u003e\u003cli\u003eDivisible by 5: if the last digit is a 0 or 5.\u003c/li\u003e\u003cli\u003eDivisible by 8: if the last three digits are divisible by 8.\u003c/li\u003e\u003cli\u003eDivisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/li\u003e\u003cli\u003eDivisible by 10: if the last digit is zero.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\"\u003eDivisible by n, Truncated-number Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = composite_divisors(n,n_str)\r\n\r\ntf = 1;\r\n\r\nend\r\n","test_suite":"%%\r\nfiletext = fileread('composite_divisors.m');\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 18;\r\nn_str = '612220032';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '612220031';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '64268410079232';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '64268410079230';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 30;\r\nn_str = '64268410079230';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 30;\r\nn_str = '64268410079220';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 90;\r\nn_str = '47829690000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 90;\r\nn_str = '47829690000001';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '101559956668416';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '101559956668417';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '3046798700052480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '3046798700052480000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '262144000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '262144000000008';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '52428800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '52428800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '4586471424';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '45864714247';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '26418075402240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '26418075402240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":76,"test_suite_updated_at":"2015-08-18T17:06:20.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-18T01:06:51.000Z","updated_at":"2026-01-11T11:13:47.000Z","published_at":"2015-08-18T01:06:51.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePursuant to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe only restriction that remains is Java.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 2: if the last digit is divisible by 2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 4: if the last two digits are divisible by 4.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 5: if the last digit is a 0 or 5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 8: if the last three digits are divisible by 8.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 10: if the last digit is zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Truncated-number Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44065,"title":"Number of even divisors of a given number","description":"Given a Number n, return the number of its even divisors without listing them.\r\n\r\nexample:\r\n\r\nn=14 ; EvenDivisors={2,14} ; y=2\r\n\r\nn=68 ; EvenDivisors={2,34,4,68} ; y=4\r\n\r\nSimilar problems are: \u003chttps://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\u003e \u003chttps://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\u003e\r\n\r\nn=64 ; EvenDivisors={2,4,8,16,32} ; y=5","description_html":"\u003cp\u003eGiven a Number n, return the number of its even divisors without listing them.\u003c/p\u003e\u003cp\u003eexample:\u003c/p\u003e\u003cp\u003en=14 ; EvenDivisors={2,14} ; y=2\u003c/p\u003e\u003cp\u003en=68 ; EvenDivisors={2,34,4,68} ; y=4\u003c/p\u003e\u003cp\u003eSimilar problems are: \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\u003c/a\u003e \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\u003c/a\u003e\u003c/p\u003e\u003cp\u003en=64 ; EvenDivisors={2,4,8,16,32} ; y=5\u003c/p\u003e","function_template":"function y = countEvenDivisors(x)\r\n  y = 0;\r\nend","test_suite":"1\r\n%%\r\nfiletext = fileread('countEvenDivisors.m');\r\nassert(isempty(strfind(filetext, 'sqrt')))\r\nassert(isempty(strfind(filetext, 'for')))\r\n2\t\r\n%%\r\nn= 6880 * 2;\r\ny_correct = 24;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n3\t\r\n%%\r\nn= 5050 * 2;\r\ny_correct = 12;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n4 \t\r\n%%\r\nn= 76576501;\r\ny_correct = 0;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n5\t\r\n%%\r\nn= 74 * 2;\r\ny_correct = 4;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n6\t\r\n%%\r\nn=14^8 *2 ;\r\ny_correct = 81;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":115733,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":52,"test_suite_updated_at":"2017-02-13T23:29:19.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-13T23:22:48.000Z","updated_at":"2026-03-09T08:39:00.000Z","published_at":"2017-02-13T23:29:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a Number n, return the number of its even divisors without listing them.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eexample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=14 ; EvenDivisors={2,14} ; y=2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=68 ; EvenDivisors={2,34,4,68} ; y=4\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSimilar problems are:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=64 ; EvenDivisors={2,4,8,16,32} ; y=5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42453,"title":"Divisible by n, prime vs. composite divisors","description":"In general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\r\n\r\n  n = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\n  n = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\n  n = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\n  n = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\n  n = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\n  n = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\n  n = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\n  n = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\n  n = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\n  n = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16 divisible by 16\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e.","description_html":"\u003cp\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\u003c/pre\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\"\u003edivisible by 16\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_type,hpf] = composite_vs_prime_divisor(n)\r\n\r\nn_type = 1;\r\nhpf = [1];\r\n\r\nend\r\n","test_suite":"%%\r\nn = 5;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 5;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 7;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 7;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 15;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,5];\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 25;\r\ntf_corr = 2; %composite factor, prime power (5^2)\r\nhpf_corr = 25;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 125;\r\ntf_corr = 2; %composite factor, prime power (5^3)\r\nhpf_corr = 125;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 20;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [4,5];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 42;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,3,7];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 18;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,9];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 29;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 29;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 39;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,13];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 64;\r\ntf_corr = 2; %composite factor, prime power (2^6)\r\nhpf_corr = 64;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 27;\r\ntf_corr = 2; %composite factor, prime power (3^3)\r\nhpf_corr = 27;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 29;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 29;\r\n\tcase 2\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 64;\r\n\t\ttf_corr = 2; %composite factor, prime power (2^6)\r\n\t\thpf_corr = 64;\r\n\tcase 2\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\n\tcase 3\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 4\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 39;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [3,13];\r\n\tcase 2\r\n\t\tn = 5;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 5;\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":113,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:29:13.000Z","updated_at":"2026-01-11T11:07:59.000Z","published_at":"2015-07-09T01:29:13.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[n = 11  |  n_type = 1 (prime)        |  hpf = [11]\\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\\\"\u003e\u003cw:r\u003e\u003cw:t\u003edivisible by 16\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44732,"title":"Highly divisible triangular number (inspired by Project Euler 12)","description":"Triangular numbers can be calculated by the sum from 1 to n. For example, the first 10 triangular numbers are:\r\n\r\n 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...\r\n\r\nAll divisors for each of these numbers are listed below\r\n\r\n 1: 1\r\n 3: 1,3\r\n 6: 1,2,3,6\r\n 10: 1,2,5,10\r\n 15: 1,3,5,15\r\n 21: 1,3,7,21\r\n 28: 1,2,4,7,14,28\r\n 36: 1,2,3,4,6,9,12,18,36\r\n 45: 1,3,5,9,15,45\r\n 55: 1,5,11,55\r\n\r\nYour challenge is to write a function that will return the value of the first triangular number to have over d divisors (d will be passed to your function).","description_html":"\u003cp\u003eTriangular numbers can be calculated by the sum from 1 to n. For example, the first 10 triangular numbers are:\u003c/p\u003e\u003cpre\u003e 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...\u003c/pre\u003e\u003cp\u003eAll divisors for each of these numbers are listed below\u003c/p\u003e\u003cpre\u003e 1: 1\r\n 3: 1,3\r\n 6: 1,2,3,6\r\n 10: 1,2,5,10\r\n 15: 1,3,5,15\r\n 21: 1,3,7,21\r\n 28: 1,2,4,7,14,28\r\n 36: 1,2,3,4,6,9,12,18,36\r\n 45: 1,3,5,9,15,45\r\n 55: 1,5,11,55\u003c/pre\u003e\u003cp\u003eYour challenge is to write a function that will return the value of the first triangular number to have over d divisors (d will be passed to your function).\u003c/p\u003e","function_template":"function y = div_tri_n(d)\r\n y = d;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp', 'regexpi', 'str2num'},'FileName','div_tri_n.m')\r\n\r\n%%\r\nassert(isequal(div_tri_n(2),6))\r\n\r\n%%\r\nassert(isequal(div_tri_n(4),28))\r\n\r\n%%\r\nassert(isequal(div_tri_n(8),36))\r\n\r\n%%\r\nassert(isequal(div_tri_n(10),120))\r\n\r\n%%\r\nassert(isequal(div_tri_n(20),630))\r\n\r\n%%\r\nassert(isequal(div_tri_n(25),2016))\r\n\r\n%%\r\nassert(isequal(div_tri_n(39),3240))\r\n\r\n%%\r\nassert(isequal(div_tri_n(40),5460))\r\n\r\n%%\r\nassert(isequal(div_tri_n(50),25200))\r\n\r\n%%\r\nassert(isequal(div_tri_n(70),25200))\r\n\r\n%%\r\nassert(isequal(div_tri_n(80),25200))\r\n\r\n%%\r\nassert(isequal(div_tri_n(100),73920))\r\n\r\n%%\r\nassert(isequal(div_tri_n(115),157080))\r\n\r\n%%\r\nassert(isequal(div_tri_n(120),157080))\r\n\r\n%%\r\nassert(isequal(div_tri_n(130),437580))","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":164,"test_suite_updated_at":"2018-08-20T16:04:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-20T15:15:06.000Z","updated_at":"2026-01-05T00:21:49.000Z","published_at":"2018-08-20T16:04:49.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\u003eTriangular numbers can be calculated by the sum from 1 to n. For example, the first 10 triangular numbers are:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...]]\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\u003eAll divisors for each of these numbers are listed below\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ 1: 1\\n 3: 1,3\\n 6: 1,2,3,6\\n 10: 1,2,5,10\\n 15: 1,3,5,15\\n 21: 1,3,7,21\\n 28: 1,2,4,7,14,28\\n 36: 1,2,3,4,6,9,12,18,36\\n 45: 1,3,5,9,15,45\\n 55: 1,5,11,55]]\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\u003eYour challenge is to write a function that will return the value of the first triangular number to have over d divisors (d will be passed to your function).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42508,"title":"Divisible by n, prime divisors from 20 to 200","description":"Pursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\r\n\r\n* 2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u003e 2048379 is not divisible by 127 since 54 is not divisible by 127.\r\n\r\n* 4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u003e 4853940 is divisible by 127.\r\n\r\nYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\r\n\r\nRestrictions on Java, mod, ceil, round, and floor are still in effect.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors Divisible by n, Truncated-number Divisors\u003e.","description_html":"\u003cp\u003ePursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\u003c/p\u003e\u003cul\u003e\u003cli\u003e2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u0026gt; 2048379 is not divisible by 127 since 54 is not divisible by 127.\u003c/li\u003e\u003c/ul\u003e\u003cul\u003e\u003cli\u003e4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u0026gt; 4853940 is divisible by 127.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\u003c/p\u003e\u003cp\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\"\u003eDivisible by n, Truncated-number Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = prime_divisors_20_to_200(n,n_str)\r\n\r\np_digits =      [23 29  31 37  41 43  47 53 59 61 67  71 73 79 83 89 97  101 103 107 109 113 127 131 137 139  149  151 157 163  167 173  179  181 191 193  197 199];\r\nlast_dig_mult = [7  3  -3 -11 -4  13 -14 16 6 -6 -20 -7 -51 8  25 9 -29 -10 -72 -32 -98 -79 -38 -13 -41 -125 -134 -15 -47 -114 -50 -121 -161 -18 -19 -135 -59 -179];\r\n\r\ntf = 1;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('prime_divisors_20_to_200.m');\r\nassert(isempty(strfind(filetext, 'rem')),'rem() forbidden')\r\nassert(isempty(strfind(filetext, 'mod')),'mod() forbidden')\r\nassert(isempty(strfind(filetext, 'round')),'round() forbidden')\r\nassert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden')\r\nassert(isempty(strfind(filetext, 'floor')),'floor() forbidden')\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 23;\r\nn_str = '943';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 23;\r\nn_str = '9430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 23;\r\nn_str = '9430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 29;\r\nn_str = '22649';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '992';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '9920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '9920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 37;\r\nn_str = '4107';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 41;\r\nn_str = '33292';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '85140';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '851400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '851400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 47;\r\nn_str = '232603';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 53;\r\nn_str = '148877';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 59;\r\nn_str = '12698688';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '61965813';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '619658130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '619658130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 67;\r\nn_str = '22319844';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 71;\r\nn_str = '25411681';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 73;\r\nn_str = '328500';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 73;\r\nn_str = '32850000000000000000000000000000000000000000000000000000000000001000000000000';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 79;\r\nn_str = '41977440';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 83;\r\nn_str = '342873';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 89;\r\nn_str = '8900000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 97;\r\nn_str = '88529281';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '104060401';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '1040604010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '1040604010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 103;\r\nn_str = '112550881';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 107;\r\nn_str = '515205';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 109;\r\nn_str = '141158161';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294000000000000000000000000113000000000000000000000000113000000000000000000000000113000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294000000000000000000000000113000000000000000000000000113000000000000000000000000113000000000000000000000112';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 127;\r\nn_str = '4853940';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 131;\r\nn_str = '294499921';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 137;\r\nn_str = '249421241';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '2685619';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '268561900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '268561900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000000000000000013';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 149;\r\nn_str = '512977200';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 151;\r\nn_str = '141160991';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 157;\r\nn_str = '607573201';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 163;\r\nn_str = '705911761';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 167;\r\nn_str = '777796321';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 173;\r\nn_str = '154963892093';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 179;\r\nn_str = '98682340334763';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 181;\r\nn_str = '35161828327081';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 191;\r\nn_str = '884089868985578';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 193;\r\nn_str = '1387488001';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 197;\r\nn_str = '27000544548887';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '328039798800';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000199000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000001991000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000199000000000000';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-17T19:05:44.000Z","updated_at":"2025-12-27T11:58:28.000Z","published_at":"2015-08-17T19:05:44.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u0026gt; 2048379 is not divisible by 127 since 54 is not divisible by 127.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u0026gt; 4853940 is divisible by 127.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Truncated-number Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":59511,"title":"Count the ones in a divisibility matrix","description":"Cody Problem 59506 asked solvers to compute the determinant of matrix consisting of ones in the first column and anywhere the row index divides the column index.\r\nWrite a function to count the ones in the matrix. For example, the 4x4 matrix given in the description of Cody Problem 59506 has 11 ones, and the 1000x1000 matrix has 8068. ","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: 93px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 46.5px; transform-origin: 407px 46.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/59506\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eCody Problem 59506\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: 290.933px 8px; transform-origin: 290.933px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e asked solvers to compute the determinant of matrix consisting of ones in the first column and anywhere the row index divides the column index.\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: 318.025px 8px; transform-origin: 318.025px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to count the ones in the matrix. For example, the 4x4 matrix given in the description of \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/59506\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eCody Problem 59506\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: 0.225px 8px; transform-origin: 0.225px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e has 11 ones, and the 1000x1000 matrix has 8068. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = divMatrixOnes(n)\r\n  y = length(find(divMatrix));\r\nend","test_suite":"%%\r\nn = 4;\r\ny = divMatrixOnes(n);\r\ny_correct = 11;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 18;\r\ny = divMatrixOnes(n);\r\ny_correct = 75;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 58;\r\ny = divMatrixOnes(n);\r\ny_correct = 304;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 411;\r\ny = divMatrixOnes(n);\r\ny_correct = 2950;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 1563;\r\ny = divMatrixOnes(n);\r\ny_correct = 13303;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 5851;\r\ny = divMatrixOnes(n);\r\ny_correct = 57516;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 99991;\r\ny = divMatrixOnes(n);\r\ny_correct = 1266618;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 4;\r\ny = divMatrixOnes(n);\r\ny_correct = 11;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 168732;\r\ny = divMatrixOnes(n);\r\ny_correct = 2225685;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 452111;\r\ny = divMatrixOnes(n);\r\ny_correct = 6409180;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 1534232;\r\ny = divMatrixOnes(n);\r\ny_correct = 23624033;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 84173652;\r\ny = divMatrixOnes(n);\r\ny_correct = 1633206463;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 2e7;\r\ny = divMatrixOnes(n);\r\ny_correct = 359313639;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 3e8;\r\ny = divMatrixOnes(n);\r\ny_correct = 6202117673;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 3678;\r\nyyyy = divMatrixOnes(divMatrixOnes(divMatrixOnes(divMatrixOnes(n))));\r\nyyyy_correct = 93760150;\r\nassert(isequal(yyyy,yyyy_correct))\r\n\r\n%%\r\nfiletext = fileread('divMatrixOnes.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'regexp'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2023-12-30T01:17:12.000Z","deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2023-12-30T01:17:04.000Z","updated_at":"2026-01-18T12:21:54.000Z","published_at":"2023-12-30T01:17:12.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/59506\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCody Problem 59506\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e asked solvers to compute the determinant of matrix consisting of ones in the first column and anywhere the row index divides the column index.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to count the ones in the matrix. For example, the 4x4 matrix given in the description of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/59506\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCody Problem 59506\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e has 11 ones, and the 1000x1000 matrix has 8068. \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":54655,"title":"Find the particular dividend","description":"It is known that once you write the sequence 10101...101 long enough, the number will be finally divisible by any odd number if it is NOT a multiple of 5. Input an odd number(not divisible by 5), count how many 1's you need to write.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 63px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 332px 31.5px; transform-origin: 332px 31.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"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: 309px 31.5px; text-align: left; transform-origin: 309px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIt is known that once you write the sequence 10101...101 long enough, the number will be finally divisible by any odd number if it is NOT a multiple of 5. Input an odd number(not divisible by 5), count how many 1's you need to write.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = pdiv(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('pdiv.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || ...\r\n          contains(filetext, 'java') || contains(filetext, 'py'); \r\nassert(~illegal)\r\n%%\r\nassert(isequal(pdiv(1),1))\r\n%%\r\nassert(isequal(pdiv(3),3))\r\n%%\r\nassert(isequal(pdiv(9),9))\r\n%%\r\nassert(isequal(pdiv(11),11))\r\n%%\r\nassert(isequal(pdiv(17),8))\r\n%%\r\nassert(isequal(pdiv(2341),1170))\r\n%%\r\nassert(isequal(pdiv(2343),1155))\r\n%%\r\nassert(isequal(pdiv(2359),168))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":2197980,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-05-17T08:38:31.000Z","updated_at":"2022-05-17T08:38:31.000Z","published_at":"2022-05-17T08:38:31.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\u003eIt is known that once you write the sequence 10101...101 long enough, the number will be finally divisible by any odd number if it is NOT a multiple of 5. Input an odd number(not divisible by 5), count how many 1's you need to write.\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":42455,"title":"Divisible by n, prime divisors - 11, 13, 17, \u0026 19","description":"Divisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\r\n\r\n* 2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u003e 2392 is divisible by 13.\r\n\r\nFor 17, subtract five times the last digit from the rest:\r\n\r\n* 3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u003e 3281 is divisible by 17.\r\n\r\nFor 19, add two times the last digit to the rest:\r\n\r\n* 16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u003e 16863 is not divisible by 19.\r\n\r\nAnd, for 11, subtract the last digit from the rest:\r\n\r\n* 269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u003e 269830 is divisible by 11.\r\n\r\nWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\r\n\r\nRestrictions on Java, mod, ceil, round, and floor are still in effect.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200 Divisible by n, prime divisors from 20 to 200\u003e.","description_html":"\u003cp\u003eDivisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u0026gt; 2392 is divisible by 13.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 17, subtract five times the last digit from the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u0026gt; 3281 is divisible by 17.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 19, add two times the last digit to the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u0026gt; 16863 is not divisible by 19.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eAnd, for 11, subtract the last digit from the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u0026gt; 269830 is divisible by 11.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\u003c/p\u003e\u003cp\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\"\u003eDivisible by n, prime divisors from 20 to 200\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = prime_divisors_11_to_20(n)\r\n\r\np_digits = [11 13 17 19];\r\ntf = zeros(1,4); %[11 13 17 19]\r\n\t\r\nend\r\n","test_suite":"%%\r\nfiletext = fileread('prime_divisors_11_to_20.m');\r\nassert(isempty(strfind(filetext, 'mod')),'mod() forbidden')\r\nassert(isempty(strfind(filetext, 'round')),'round() forbidden')\r\nassert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden')\r\nassert(isempty(strfind(filetext, 'floor')),'floor() forbidden')\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = '143';\r\ntf = [1 1 0 0]; %[11 13 17 19]\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '187';\r\ntf = [1 0 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '221';\r\ntf = [0 1 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '247';\r\ntf = [0 1 0 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '46189';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '2133423721';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '233296158667';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010101';\r\ntf = [0 0 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010103';\r\ntf = [0 1 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010107';\r\ntf = [0 0 0 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%\r\nn = '14300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = [1 1 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '14300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = [0 0 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '22100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = [0 1 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '221';\r\n\t\ttf = [0 1 1 0];\r\n\tcase 2\r\n\t\tn = '233296158667';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 3\r\n\t\tn = '46189';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 4\r\n\t\tn = '247';\r\n\t\ttf = [0 1 0 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '187';\r\n\t\ttf = [1 0 1 0];\r\n\tcase 2\r\n\t\tn = '143';\r\n\t\ttf = [1 1 0 0];\r\n\tcase 3\r\n\t\tn = '221';\r\n\t\ttf = [0 1 1 0];\r\n\tcase 4\r\n\t\tn = '233296158667';\r\n\t\ttf = [1 1 1 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '2133423721';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 2\r\n\t\tn = '46189';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 3\r\n\t\tn = '187';\r\n\t\ttf = [1 0 1 0];\r\n\tcase 4\r\n\t\tn = '247';\r\n\t\ttf = [0 1 0 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":73,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T04:18:06.000Z","updated_at":"2025-12-28T20:47:42.000Z","published_at":"2015-07-09T04:18:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u0026gt; 2392 is divisible by 13.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 17, subtract five times the last digit from the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u0026gt; 3281 is divisible by 17.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 19, add two times the last digit to the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u0026gt; 16863 is not divisible by 19.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAnd, for 11, subtract the last digit from the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u0026gt; 269830 is divisible by 11.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors from 20 to 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":42509,"title":"Divisible by n, Truncated-number Divisors","description":"Some divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\r\n\r\n* 25: The last two digits must be divisible by 25.\r\n* 32: The last five digits must be divisible by 32.\r\n* 50: The last two digits must be 00 or 50.\r\n* 64: The last six digits must be divisible by 64.\r\n* 75: The number must be divisible by 3 (can be done by a \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3 simple sum\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25). \r\n* 100: The last two digits must be 00.\r\n* 125: The last three digits must be divisible by 125.\r\n* 128: The last seven digits must be divisible by 128.\r\n* 256: The last eight digits must be divisible by 256.\r\n* 512: The last nine digits must be divisible by 512.\r\n\r\nThe only restriction that remains is Java.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200 Divisible by n, prime divisors from 20 to 200\u003e. Next problem \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors Divisible by n, Composite Divisors\u003e.","description_html":"\u003cp\u003eSome divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\u003c/p\u003e\u003cul\u003e\u003cli\u003e25: The last two digits must be divisible by 25.\u003c/li\u003e\u003cli\u003e32: The last five digits must be divisible by 32.\u003c/li\u003e\u003cli\u003e50: The last two digits must be 00 or 50.\u003c/li\u003e\u003cli\u003e64: The last six digits must be divisible by 64.\u003c/li\u003e\u003cli\u003e75: The number must be divisible by 3 (can be done by a \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3\"\u003esimple sum\u003c/a\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25).\u003c/li\u003e\u003cli\u003e100: The last two digits must be 00.\u003c/li\u003e\u003cli\u003e125: The last three digits must be divisible by 125.\u003c/li\u003e\u003cli\u003e128: The last seven digits must be divisible by 128.\u003c/li\u003e\u003cli\u003e256: The last eight digits must be divisible by 256.\u003c/li\u003e\u003cli\u003e512: The last nine digits must be divisible by 512.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe only restriction that remains is Java.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\"\u003eDivisible by n, prime divisors from 20 to 200\u003c/a\u003e. Next problem \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors\"\u003eDivisible by n, Composite Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = truncated_number_divisors(n,n_str)\r\n\r\ntf = 1;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('truncated_number_divisors.m');\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 25;\r\nn_str = '123456789025';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 25;\r\nn_str = '1234567890250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 25;\r\nn_str = '1234567890250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 32;\r\nn_str = '213546116579874651316984601654958847098406516051320150408460840649084790870510201378465465046760406541654604601561065140637860373703970644065166540616510650165409684098049804165016510320540540645106056501650165709804650860466840650156106165028224';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 32;\r\nn_str = '213546116579874651316984601654958847098406516051320150408460840649084790870510201378465465046760406541654604601561065140637860373703970644065166540616510650165409684098049804165016510320540540645106056501650165709804650860466840650156106165028227';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '15668045014654987098045406540500';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '50440984098480149540561065106510516501615001';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 50;\r\nn_str = '50440984098480149540561065106510516501615001897241387234587503198417059813645097867234985672307485679813709582304957234897659832746098514949188412929894824924949334949777378994191995216173718811313515141418186186382171646871681436817897678350';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404996';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489216';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 64;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489217';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 75;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499175';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 75;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499275';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992750';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992700';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890404992';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 100;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499200';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789040499200125';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111489216';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 125;\r\nn_str = '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111114892375';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 128;\r\nn_str = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111148923751048576';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 128;\r\nn_str = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111148923751048578';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 256;\r\nn_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678904049917516777216';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 256;\r\nn_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678904049917516777210';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000134217728';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000536870912';\r\ntf = 1;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 512;\r\nn_str = '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000536870914';\r\ntf = 0;\r\nassert(isequal(truncated_number_divisors(n,n_str),tf))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-17T21:32:54.000Z","updated_at":"2026-01-11T10:42:54.000Z","published_at":"2015-08-17T21:32:54.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSome divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e25: The last two digits must be divisible by 25.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e32: The last five digits must be divisible by 32.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e50: The last two digits must be 00 or 50.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e64: The last six digits must be divisible by 64.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e75: The number must be divisible by 3 (can be done by a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42405-divisible-by-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esimple sum\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) and end in 00, 25, 50, or 75 (last two digits divisible by 25).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e100: The last two digits must be 00.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e125: The last three digits must be divisible by 125.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e128: The last seven digits must be divisible by 128.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e256: The last eight digits must be divisible by 256.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e512: The last nine digits must be divisible by 512.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe only restriction that remains is Java.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors from 20 to 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42510-divisible-by-n-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Composite Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42454,"title":"Divisible by n, prime divisors (including powers)","description":"For this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\r\n\r\n  n = 1:10;\r\n  n_p = [2 3 4 5 7 8 9];\r\n\r\nSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e.","description_html":"\u003cp\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1:10;\r\nn_p = [2 3 4 5 7 8 9];\r\n\u003c/pre\u003e\u003cp\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_p] = prime_divisors_incl_powers(n)\r\n\r\nn_p = 1;\r\n\r\nend","test_suite":"%%\r\nn = 1:10;\r\nn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = [2:7 12:17 10 42:55 11 19:29];\r\nn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1:100;\r\nn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 41:59;\r\nn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 100:200;\r\nn_p = [101 103 107 109 113 121 125 127 128 131 137 139 149 151 157 163 167 169 173 179 181 191 193 197 199]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1000:1111;\r\nn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:10;\r\n\t\tn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 3\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\n\tcase 3\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = 1000:1111;\r\n\t\tn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":95,"test_suite_updated_at":"2017-03-20T19:03:08.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:55:28.000Z","updated_at":"2026-01-11T12:28:45.000Z","published_at":"2015-07-09T01:55:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[n = 1:10;\\nn_p = [2 3 4 5 7 8 9];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42510,"title":"Divisible by n, Composite Divisors","description":"Pursuant to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\r\n\r\nAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\r\n\r\nThe only restriction that remains is Java.\r\n\r\n* Divisible by 2: if the last digit is divisible by 2.\r\n* Divisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\r\n* Divisible by 4: if the last two digits are divisible by 4.\r\n* Divisible by 5: if the last digit is a 0 or 5.\r\n* Divisible by 8: if the last three digits are divisible by 8.\r\n* Divisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\r\n* Divisible by 10: if the last digit is zero.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors Divisible by n, Truncated-number Divisors\u003e.","description_html":"\u003cp\u003ePursuant to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\u003c/p\u003e\u003cp\u003eAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\u003c/p\u003e\u003cp\u003eThe only restriction that remains is Java.\u003c/p\u003e\u003cul\u003e\u003cli\u003eDivisible by 2: if the last digit is divisible by 2.\u003c/li\u003e\u003cli\u003eDivisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/li\u003e\u003cli\u003eDivisible by 4: if the last two digits are divisible by 4.\u003c/li\u003e\u003cli\u003eDivisible by 5: if the last digit is a 0 or 5.\u003c/li\u003e\u003cli\u003eDivisible by 8: if the last three digits are divisible by 8.\u003c/li\u003e\u003cli\u003eDivisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/li\u003e\u003cli\u003eDivisible by 10: if the last digit is zero.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\"\u003eDivisible by n, Truncated-number Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = composite_divisors(n,n_str)\r\n\r\ntf = 1;\r\n\r\nend\r\n","test_suite":"%%\r\nfiletext = fileread('composite_divisors.m');\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 18;\r\nn_str = '612220032';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '612220031';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '64268410079232';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '64268410079230';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 18;\r\nn_str = '192805230237696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 30;\r\nn_str = '64268410079230';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 30;\r\nn_str = '64268410079220';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 90;\r\nn_str = '47829690000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 90;\r\nn_str = '47829690000001';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '101559956668416';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '101559956668417';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '3046798700052480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 36;\r\nn_str = '3046798700052480000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '262144000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '262144000000008';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '52428800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 40;\r\nn_str = '52428800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '4586471424';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '45864714247';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '26418075402240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020';\r\ntf = 0;\r\nassert(isequal(composite_divisors(n,n_str),tf))\r\n\r\n%%\r\nn = 24;\r\nn_str = '26418075402240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(composite_divisors(n,n_str),tf))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":76,"test_suite_updated_at":"2015-08-18T17:06:20.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-18T01:06:51.000Z","updated_at":"2026-01-11T11:13:47.000Z","published_at":"2015-08-18T01:06:51.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePursuant to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highest-power factorization of the divisor. Divisibility of n_str can then be determined by testing against each highest-power factor. For simplicity, this problem is restricted to numbers that contain the following as highest-power factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highest-power factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highest-power factors.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe only restriction that remains is Java.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 2: if the last digit is divisible by 2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 4: if the last two digits are divisible by 4.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 5: if the last digit is a 0 or 5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 8: if the last three digits are divisible by 8.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a single-digit number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by 10: if the last digit is zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Truncated-number Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44065,"title":"Number of even divisors of a given number","description":"Given a Number n, return the number of its even divisors without listing them.\r\n\r\nexample:\r\n\r\nn=14 ; EvenDivisors={2,14} ; y=2\r\n\r\nn=68 ; EvenDivisors={2,34,4,68} ; y=4\r\n\r\nSimilar problems are: \u003chttps://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\u003e \u003chttps://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\u003e\r\n\r\nn=64 ; EvenDivisors={2,4,8,16,32} ; y=5","description_html":"\u003cp\u003eGiven a Number n, return the number of its even divisors without listing them.\u003c/p\u003e\u003cp\u003eexample:\u003c/p\u003e\u003cp\u003en=14 ; EvenDivisors={2,14} ; y=2\u003c/p\u003e\u003cp\u003en=68 ; EvenDivisors={2,34,4,68} ; y=4\u003c/p\u003e\u003cp\u003eSimilar problems are: \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\u003c/a\u003e \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\u003c/a\u003e\u003c/p\u003e\u003cp\u003en=64 ; EvenDivisors={2,4,8,16,32} ; y=5\u003c/p\u003e","function_template":"function y = countEvenDivisors(x)\r\n  y = 0;\r\nend","test_suite":"1\r\n%%\r\nfiletext = fileread('countEvenDivisors.m');\r\nassert(isempty(strfind(filetext, 'sqrt')))\r\nassert(isempty(strfind(filetext, 'for')))\r\n2\t\r\n%%\r\nn= 6880 * 2;\r\ny_correct = 24;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n3\t\r\n%%\r\nn= 5050 * 2;\r\ny_correct = 12;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n4 \t\r\n%%\r\nn= 76576501;\r\ny_correct = 0;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n5\t\r\n%%\r\nn= 74 * 2;\r\ny_correct = 4;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n6\t\r\n%%\r\nn=14^8 *2 ;\r\ny_correct = 81;\r\nassert(isequal(countEvenDivisors(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":115733,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":52,"test_suite_updated_at":"2017-02-13T23:29:19.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-13T23:22:48.000Z","updated_at":"2026-03-09T08:39:00.000Z","published_at":"2017-02-13T23:29:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a Number n, return the number of its even divisors without listing them.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eexample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=14 ; EvenDivisors={2,14} ; y=2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=68 ; EvenDivisors={2,34,4,68} ; y=4\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSimilar problems are:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/42791-number-of-divisors-of-a-given-number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/1025-divisors-of-an-integer\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=64 ; EvenDivisors={2,4,8,16,32} ; y=5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42453,"title":"Divisible by n, prime vs. composite divisors","description":"In general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\r\n\r\n  n = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\n  n = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\n  n = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\n  n = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\n  n = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\n  n = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\n  n = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\n  n = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\n  n = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\n  n = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16 divisible by 16\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e.","description_html":"\u003cp\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\u003c/pre\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\"\u003edivisible by 16\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_type,hpf] = composite_vs_prime_divisor(n)\r\n\r\nn_type = 1;\r\nhpf = [1];\r\n\r\nend\r\n","test_suite":"%%\r\nn = 5;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 5;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 7;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 7;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 15;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,5];\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 25;\r\ntf_corr = 2; %composite factor, prime power (5^2)\r\nhpf_corr = 25;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 125;\r\ntf_corr = 2; %composite factor, prime power (5^3)\r\nhpf_corr = 125;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 20;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [4,5];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 42;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,3,7];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 18;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,9];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 29;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 29;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 39;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,13];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 64;\r\ntf_corr = 2; %composite factor, prime power (2^6)\r\nhpf_corr = 64;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 27;\r\ntf_corr = 2; %composite factor, prime power (3^3)\r\nhpf_corr = 27;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 29;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 29;\r\n\tcase 2\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 64;\r\n\t\ttf_corr = 2; %composite factor, prime power (2^6)\r\n\t\thpf_corr = 64;\r\n\tcase 2\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\n\tcase 3\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 4\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 39;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [3,13];\r\n\tcase 2\r\n\t\tn = 5;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 5;\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":113,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:29:13.000Z","updated_at":"2026-01-11T11:07:59.000Z","published_at":"2015-07-09T01:29:13.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[n = 11  |  n_type = 1 (prime)        |  hpf = [11]\\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\\\"\u003e\u003cw:r\u003e\u003cw:t\u003edivisible by 16\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44732,"title":"Highly divisible triangular number (inspired by Project Euler 12)","description":"Triangular numbers can be calculated by the sum from 1 to n. For example, the first 10 triangular numbers are:\r\n\r\n 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...\r\n\r\nAll divisors for each of these numbers are listed below\r\n\r\n 1: 1\r\n 3: 1,3\r\n 6: 1,2,3,6\r\n 10: 1,2,5,10\r\n 15: 1,3,5,15\r\n 21: 1,3,7,21\r\n 28: 1,2,4,7,14,28\r\n 36: 1,2,3,4,6,9,12,18,36\r\n 45: 1,3,5,9,15,45\r\n 55: 1,5,11,55\r\n\r\nYour challenge is to write a function that will return the value of the first triangular number to have over d divisors (d will be passed to your function).","description_html":"\u003cp\u003eTriangular numbers can be calculated by the sum from 1 to n. For example, the first 10 triangular numbers are:\u003c/p\u003e\u003cpre\u003e 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...\u003c/pre\u003e\u003cp\u003eAll divisors for each of these numbers are listed below\u003c/p\u003e\u003cpre\u003e 1: 1\r\n 3: 1,3\r\n 6: 1,2,3,6\r\n 10: 1,2,5,10\r\n 15: 1,3,5,15\r\n 21: 1,3,7,21\r\n 28: 1,2,4,7,14,28\r\n 36: 1,2,3,4,6,9,12,18,36\r\n 45: 1,3,5,9,15,45\r\n 55: 1,5,11,55\u003c/pre\u003e\u003cp\u003eYour challenge is to write a function that will return the value of the first triangular number to have over d divisors (d will be passed to your function).\u003c/p\u003e","function_template":"function y = div_tri_n(d)\r\n y = d;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp', 'regexpi', 'str2num'},'FileName','div_tri_n.m')\r\n\r\n%%\r\nassert(isequal(div_tri_n(2),6))\r\n\r\n%%\r\nassert(isequal(div_tri_n(4),28))\r\n\r\n%%\r\nassert(isequal(div_tri_n(8),36))\r\n\r\n%%\r\nassert(isequal(div_tri_n(10),120))\r\n\r\n%%\r\nassert(isequal(div_tri_n(20),630))\r\n\r\n%%\r\nassert(isequal(div_tri_n(25),2016))\r\n\r\n%%\r\nassert(isequal(div_tri_n(39),3240))\r\n\r\n%%\r\nassert(isequal(div_tri_n(40),5460))\r\n\r\n%%\r\nassert(isequal(div_tri_n(50),25200))\r\n\r\n%%\r\nassert(isequal(div_tri_n(70),25200))\r\n\r\n%%\r\nassert(isequal(div_tri_n(80),25200))\r\n\r\n%%\r\nassert(isequal(div_tri_n(100),73920))\r\n\r\n%%\r\nassert(isequal(div_tri_n(115),157080))\r\n\r\n%%\r\nassert(isequal(div_tri_n(120),157080))\r\n\r\n%%\r\nassert(isequal(div_tri_n(130),437580))","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":164,"test_suite_updated_at":"2018-08-20T16:04:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-20T15:15:06.000Z","updated_at":"2026-01-05T00:21:49.000Z","published_at":"2018-08-20T16:04:49.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\u003eTriangular numbers can be calculated by the sum from 1 to n. For example, the first 10 triangular numbers are:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...]]\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\u003eAll divisors for each of these numbers are listed below\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ 1: 1\\n 3: 1,3\\n 6: 1,2,3,6\\n 10: 1,2,5,10\\n 15: 1,3,5,15\\n 21: 1,3,7,21\\n 28: 1,2,4,7,14,28\\n 36: 1,2,3,4,6,9,12,18,36\\n 45: 1,3,5,9,15,45\\n 55: 1,5,11,55]]\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\u003eYour challenge is to write a function that will return the value of the first triangular number to have over d divisors (d will be passed to your function).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42508,"title":"Divisible by n, prime divisors from 20 to 200","description":"Pursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\r\n\r\n* 2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u003e 2048379 is not divisible by 127 since 54 is not divisible by 127.\r\n\r\n* 4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u003e 4853940 is divisible by 127.\r\n\r\nYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\r\n\r\nRestrictions on Java, mod, ceil, round, and floor are still in effect.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors Divisible by n, Truncated-number Divisors\u003e.","description_html":"\u003cp\u003ePursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\u003c/p\u003e\u003cul\u003e\u003cli\u003e2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u0026gt; 2048379 is not divisible by 127 since 54 is not divisible by 127.\u003c/li\u003e\u003c/ul\u003e\u003cul\u003e\u003cli\u003e4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u0026gt; 4853940 is divisible by 127.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\u003c/p\u003e\u003cp\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\"\u003eDivisible by n, Truncated-number Divisors\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = prime_divisors_20_to_200(n,n_str)\r\n\r\np_digits =      [23 29  31 37  41 43  47 53 59 61 67  71 73 79 83 89 97  101 103 107 109 113 127 131 137 139  149  151 157 163  167 173  179  181 191 193  197 199];\r\nlast_dig_mult = [7  3  -3 -11 -4  13 -14 16 6 -6 -20 -7 -51 8  25 9 -29 -10 -72 -32 -98 -79 -38 -13 -41 -125 -134 -15 -47 -114 -50 -121 -161 -18 -19 -135 -59 -179];\r\n\r\ntf = 1;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('prime_divisors_20_to_200.m');\r\nassert(isempty(strfind(filetext, 'rem')),'rem() forbidden')\r\nassert(isempty(strfind(filetext, 'mod')),'mod() forbidden')\r\nassert(isempty(strfind(filetext, 'round')),'round() forbidden')\r\nassert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden')\r\nassert(isempty(strfind(filetext, 'floor')),'floor() forbidden')\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = 23;\r\nn_str = '943';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 23;\r\nn_str = '9430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 23;\r\nn_str = '9430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 29;\r\nn_str = '22649';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '992';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '9920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 31;\r\nn_str = '9920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 37;\r\nn_str = '4107';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 41;\r\nn_str = '33292';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '85140';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '851400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 43;\r\nn_str = '851400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 47;\r\nn_str = '232603';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 53;\r\nn_str = '148877';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 59;\r\nn_str = '12698688';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '61965813';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '619658130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 61;\r\nn_str = '619658130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 67;\r\nn_str = '22319844';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 71;\r\nn_str = '25411681';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 73;\r\nn_str = '328500';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 73;\r\nn_str = '32850000000000000000000000000000000000000000000000000000000000001000000000000';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 79;\r\nn_str = '41977440';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 83;\r\nn_str = '342873';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 89;\r\nn_str = '8900000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 97;\r\nn_str = '88529281';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '104060401';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '1040604010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 101;\r\nn_str = '1040604010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 103;\r\nn_str = '112550881';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 107;\r\nn_str = '515205';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 109;\r\nn_str = '141158161';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294000000000000000000000000113000000000000000000000000113000000000000000000000000113000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 113;\r\nn_str = '2151294000000000000000000000000113000000000000000000000000113000000000000000000000000113000000000000000000000112';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 127;\r\nn_str = '4853940';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 131;\r\nn_str = '294499921';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 137;\r\nn_str = '249421241';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '2685619';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '268561900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 139;\r\nn_str = '268561900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013900000000000000000000000000000000000000000000000000000000000000000000000013';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 149;\r\nn_str = '512977200';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 151;\r\nn_str = '141160991';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 157;\r\nn_str = '607573201';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 163;\r\nn_str = '705911761';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 167;\r\nn_str = '777796321';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 173;\r\nn_str = '154963892093';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 179;\r\nn_str = '98682340334763';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 181;\r\nn_str = '35161828327081';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 191;\r\nn_str = '884089868985578';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 193;\r\nn_str = '1387488001';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 197;\r\nn_str = '27000544548887';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '328039798800';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000199000000000000';\r\ntf = 1;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n\r\n%%\r\nn = 199;\r\nn_str = '32803979880000000000000000000000000000000000000000000000000000000000000001991000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001990000000000000000000000000000000000199000000000000';\r\ntf = 0;\r\nassert(isequal(prime_divisors_20_to_200(n,n_str),tf))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-08-17T19:05:44.000Z","updated_at":"2025-12-27T11:58:28.000Z","published_at":"2015-08-17T19:05:44.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -\u0026gt; 2048379 is not divisible by 127 since 54 is not divisible by 127.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -\u0026gt; 4853940 is divisible by 127.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42509-divisible-by-n-truncated-number-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, Truncated-number Divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":59511,"title":"Count the ones in a divisibility matrix","description":"Cody Problem 59506 asked solvers to compute the determinant of matrix consisting of ones in the first column and anywhere the row index divides the column index.\r\nWrite a function to count the ones in the matrix. For example, the 4x4 matrix given in the description of Cody Problem 59506 has 11 ones, and the 1000x1000 matrix has 8068. ","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: 93px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 46.5px; transform-origin: 407px 46.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/59506\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eCody Problem 59506\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: 290.933px 8px; transform-origin: 290.933px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e asked solvers to compute the determinant of matrix consisting of ones in the first column and anywhere the row index divides the column index.\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: 318.025px 8px; transform-origin: 318.025px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to count the ones in the matrix. For example, the 4x4 matrix given in the description of \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/59506\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eCody Problem 59506\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: 0.225px 8px; transform-origin: 0.225px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e has 11 ones, and the 1000x1000 matrix has 8068. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = divMatrixOnes(n)\r\n  y = length(find(divMatrix));\r\nend","test_suite":"%%\r\nn = 4;\r\ny = divMatrixOnes(n);\r\ny_correct = 11;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 18;\r\ny = divMatrixOnes(n);\r\ny_correct = 75;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 58;\r\ny = divMatrixOnes(n);\r\ny_correct = 304;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 411;\r\ny = divMatrixOnes(n);\r\ny_correct = 2950;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 1563;\r\ny = divMatrixOnes(n);\r\ny_correct = 13303;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 5851;\r\ny = divMatrixOnes(n);\r\ny_correct = 57516;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 99991;\r\ny = divMatrixOnes(n);\r\ny_correct = 1266618;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 4;\r\ny = divMatrixOnes(n);\r\ny_correct = 11;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 168732;\r\ny = divMatrixOnes(n);\r\ny_correct = 2225685;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 452111;\r\ny = divMatrixOnes(n);\r\ny_correct = 6409180;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 1534232;\r\ny = divMatrixOnes(n);\r\ny_correct = 23624033;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 84173652;\r\ny = divMatrixOnes(n);\r\ny_correct = 1633206463;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 2e7;\r\ny = divMatrixOnes(n);\r\ny_correct = 359313639;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 3e8;\r\ny = divMatrixOnes(n);\r\ny_correct = 6202117673;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 3678;\r\nyyyy = divMatrixOnes(divMatrixOnes(divMatrixOnes(divMatrixOnes(n))));\r\nyyyy_correct = 93760150;\r\nassert(isequal(yyyy,yyyy_correct))\r\n\r\n%%\r\nfiletext = fileread('divMatrixOnes.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'regexp'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2023-12-30T01:17:12.000Z","deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2023-12-30T01:17:04.000Z","updated_at":"2026-01-18T12:21:54.000Z","published_at":"2023-12-30T01:17:12.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/59506\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCody Problem 59506\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e asked solvers to compute the determinant of matrix consisting of ones in the first column and anywhere the row index divides the column index.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to count the ones in the matrix. For example, the 4x4 matrix given in the description of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/59506\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCody Problem 59506\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e has 11 ones, and the 1000x1000 matrix has 8068. \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":54655,"title":"Find the particular dividend","description":"It is known that once you write the sequence 10101...101 long enough, the number will be finally divisible by any odd number if it is NOT a multiple of 5. Input an odd number(not divisible by 5), count how many 1's you need to write.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 63px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 332px 31.5px; transform-origin: 332px 31.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"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: 309px 31.5px; text-align: left; transform-origin: 309px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIt is known that once you write the sequence 10101...101 long enough, the number will be finally divisible by any odd number if it is NOT a multiple of 5. Input an odd number(not divisible by 5), count how many 1's you need to write.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = pdiv(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('pdiv.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || ...\r\n          contains(filetext, 'java') || contains(filetext, 'py'); \r\nassert(~illegal)\r\n%%\r\nassert(isequal(pdiv(1),1))\r\n%%\r\nassert(isequal(pdiv(3),3))\r\n%%\r\nassert(isequal(pdiv(9),9))\r\n%%\r\nassert(isequal(pdiv(11),11))\r\n%%\r\nassert(isequal(pdiv(17),8))\r\n%%\r\nassert(isequal(pdiv(2341),1170))\r\n%%\r\nassert(isequal(pdiv(2343),1155))\r\n%%\r\nassert(isequal(pdiv(2359),168))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":2197980,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-05-17T08:38:31.000Z","updated_at":"2022-05-17T08:38:31.000Z","published_at":"2022-05-17T08:38:31.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\u003eIt is known that once you write the sequence 10101...101 long enough, the number will be finally divisible by any odd number if it is NOT a multiple of 5. Input an odd number(not divisible by 5), count how many 1's you need to write.\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":42455,"title":"Divisible by n, prime divisors - 11, 13, 17, \u0026 19","description":"Divisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\r\n\r\n* 2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u003e 2392 is divisible by 13.\r\n\r\nFor 17, subtract five times the last digit from the rest:\r\n\r\n* 3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u003e 3281 is divisible by 17.\r\n\r\nFor 19, add two times the last digit to the rest:\r\n\r\n* 16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u003e 16863 is not divisible by 19.\r\n\r\nAnd, for 11, subtract the last digit from the rest:\r\n\r\n* 269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u003e 269830 is divisible by 11.\r\n\r\nWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\r\n\r\nRestrictions on Java, mod, ceil, round, and floor are still in effect.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200 Divisible by n, prime divisors from 20 to 200\u003e.","description_html":"\u003cp\u003eDivisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u0026gt; 2392 is divisible by 13.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 17, subtract five times the last digit from the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u0026gt; 3281 is divisible by 17.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 19, add two times the last digit to the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u0026gt; 16863 is not divisible by 19.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eAnd, for 11, subtract the last digit from the rest:\u003c/p\u003e\u003cul\u003e\u003cli\u003e269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u0026gt; 269830 is divisible by 11.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\u003c/p\u003e\u003cp\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\"\u003eDivisible by n, prime divisors from 20 to 200\u003c/a\u003e.\u003c/p\u003e","function_template":"function [tf] = prime_divisors_11_to_20(n)\r\n\r\np_digits = [11 13 17 19];\r\ntf = zeros(1,4); %[11 13 17 19]\r\n\t\r\nend\r\n","test_suite":"%%\r\nfiletext = fileread('prime_divisors_11_to_20.m');\r\nassert(isempty(strfind(filetext, 'mod')),'mod() forbidden')\r\nassert(isempty(strfind(filetext, 'round')),'round() forbidden')\r\nassert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden')\r\nassert(isempty(strfind(filetext, 'floor')),'floor() forbidden')\r\nassert(isempty(strfind(filetext, 'java')),'java forbidden')\r\n\r\n%%\r\nn = '143';\r\ntf = [1 1 0 0]; %[11 13 17 19]\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '187';\r\ntf = [1 0 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '221';\r\ntf = [0 1 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '247';\r\ntf = [0 1 0 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '46189';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '2133423721';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '233296158667';\r\ntf = [1 1 1 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010101';\r\ntf = [0 0 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010103';\r\ntf = [0 1 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '1011001000101010101010110101001010101001010101001001011010101000101010101010101010010101010010101010100101010101001100101010010107';\r\ntf = [0 0 0 1];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%\r\nn = '14300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = [1 1 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '14300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';\r\ntf = [0 0 0 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%%\r\nn = '22100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\ntf = [0 1 1 0];\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '221';\r\n\t\ttf = [0 1 1 0];\r\n\tcase 2\r\n\t\tn = '233296158667';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 3\r\n\t\tn = '46189';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 4\r\n\t\tn = '247';\r\n\t\ttf = [0 1 0 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '187';\r\n\t\ttf = [1 0 1 0];\r\n\tcase 2\r\n\t\tn = '143';\r\n\t\ttf = [1 1 0 0];\r\n\tcase 3\r\n\t\tn = '221';\r\n\t\ttf = [0 1 1 0];\r\n\tcase 4\r\n\t\tn = '233296158667';\r\n\t\ttf = [1 1 1 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n\r\n%% anti-cheating test\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = '2133423721';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 2\r\n\t\tn = '46189';\r\n\t\ttf = [1 1 1 1];\r\n\tcase 3\r\n\t\tn = '187';\r\n\t\ttf = [1 0 1 0];\r\n\tcase 4\r\n\t\tn = '247';\r\n\t\ttf = [0 1 0 1];\r\nend\r\nassert(isequal(prime_divisors_11_to_20(n),tf))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":73,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T04:18:06.000Z","updated_at":"2025-12-28T20:47:42.000Z","published_at":"2015-07-09T04:18:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivisibility checks against prime numbers can all be accomplished with the same routine, applied recursively, consisting of add or subtract x times the last digit to or from the remaining number. For example, for 13, add four times the last digit to the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2392: 239 + 4*2 = 247: 24 + 4*7 = 52: 5 + 4*2 = 13 -\u0026gt; 2392 is divisible by 13.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 17, subtract five times the last digit from the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3281: 328 - 5*1 = 323: 32 - 5*3 = 17 -\u0026gt; 3281 is divisible by 17.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 19, add two times the last digit to the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e16863: 1686 + 2*3 = 1692: 169 + 2*2 = 173: 17 + 2*3 = 23: 2 + 2*3 = 8 -\u0026gt; 16863 is not divisible by 19.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAnd, for 11, subtract the last digit from the rest:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e269830: 26983 - 0 = 26983: 2698 - 3 = 2695: 269 - 5 = 264: 26 - 4 = 22: 2 - 2 = 0 -\u0026gt; 269830 is divisible by 11.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to return a true-false vector for the prime numbers in the 11:20 range ([11 13 17 19]) based on a number supplied as a string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRestrictions on Java, mod, ceil, round, and floor are still in effect.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42508-divisible-by-n-prime-divisors-from-20-to-200\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors from 20 to 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"divisor\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"divisor\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"divisor\"","","\"","divisor","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f19492e88f8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f19492e8858\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f19492e7f98\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f19492e8b78\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f19492e8ad8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f19492e8a38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f19492e8998\u003e":"tag:\"divisor\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f19492e8998\u003e":"tag:\"divisor\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"divisor\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"divisor\"","","\"","divisor","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f19492e88f8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f19492e8858\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f19492e7f98\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f19492e8b78\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f19492e8ad8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f19492e8a38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f19492e8998\u003e":"tag:\"divisor\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f19492e8998\u003e":"tag:\"divisor\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":42509,"difficulty_rating":"easy-medium"},{"id":42454,"difficulty_rating":"easy-medium"},{"id":42510,"difficulty_rating":"easy-medium"},{"id":44065,"difficulty_rating":"easy-medium"},{"id":42453,"difficulty_rating":"easy-medium"},{"id":44732,"difficulty_rating":"medium"},{"id":42508,"difficulty_rating":"medium"},{"id":59511,"difficulty_rating":"medium"},{"id":54655,"difficulty_rating":"medium"},{"id":42455,"difficulty_rating":"medium"}]}}