Cody

Problem 1087. Magic is simple (for beginners)

Solution 1894648

Submitted on 8 Aug 2019 by Yuumi Ozaki
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 3; y_correct = 15; assert(isequal(magic_sum(n),y_correct))

m = 0 m = 8 m = 9 m = 15

2   Pass
n = 5; y_correct = 65; assert(isequal(magic_sum(n),y_correct))

m = 0 m = 17 m = 41 m = 42 m = 50 m = 65

3   Pass
n = 7; y_correct = 175; assert(isequal(magic_sum(n),y_correct))

m = 0 m = 30 m = 69 m = 117 m = 118 m = 128 m = 147 m = 175

4   Pass
n = 8; y_correct = 260; assert(isequal(magic_sum(n),y_correct))

m = 0 m = 64 m = 66 m = 69 m = 130 m = 190 m = 196 m = 203 m = 260

5   Pass
n = 20; y_correct = 4010; assert(isequal(magic_sum(n),y_correct))

m = 0 m = 400 m = 402 m = 405 m = 802 m = 1198 m = 1204 m = 1211 m = 1604 m = 1996 m = 2006 m = 2017 m = 2406 m = 2794 m = 2808 m = 2823 m = 3208 m = 3592 m = 3610 m = 3629 m = 4010

6   Pass
n = 100; y_correct = 500050; assert(isequal(magic_sum(n),y_correct))

m = 0 m = 10000 m = 10002 m = 10005 m = 20002 m = 29998 m = 30004 m = 30011 m = 40004 m = 49996 m = 50006 m = 50017 m = 60006 m = 69994 m = 70008 m = 70023 m = 80008 m = 89992 m = 90010 m = 90029 m = 100010 m = 109990 m = 110012 m = 110035 m = 120012 m = 129988 m = 130014 m = 130041 m = 140014 m = 149986 m = 150016 m = 150047 m = 160016 m = 169984 m = 170018 m = 170053 m = 180018 m = 189982 m = 190020 m = 190059 m = 200020 m = 209980 m = 210022 m = 210065 m = 220022 m = 229978 m = 230024 m = 230071 m = 240024 m = 249976 m = 250026 m = 250077 m = 260026 m = 269974 m = 270028 m = 270083 m = 280028 m = 289972 m = 290030 m = 290089 m = 300030 m = 309970 m = 310032 m = 310095 m = 320032 m = 329968 m = 330034 m = 330101 m = 340034 m = 349966 m = 350036 m = 350107 m = 360036 m = 369964 m = 370038 m = 370113 m = 380038 m = 389962 m = 390040 m = 390119 m = 400040 m = 409960 m = 410042 m = 410125 m = 420042 m = 429958 m = 430044 m = 430131 m = 440044 m = 449956 m = 450046 m = 450137 m = 460046 m = 469954 m = 470048 m = 470143 m = 480048 m = 489952 m = 490050 m = 490149 m = 500050

7   Pass
n = 200; y_correct = 4000100; assert(isequal(magic_sum(n),y_correct))

m = 0 m = 40000 m = 40002 m = 40005 m = 80002 m = 119998 m = 120004 m = 120011 m = 160004 m = 199996 m = 200006 m = 200017 m = 240006 m = 279994 m = 280008 m = 280023 m = 320008 m = 359992 m = 360010 m = 360029 m = 400010 m = 439990 m = 440012 m = 440035 m = 480012 m = 519988 m = 520014 m = 520041 m = 560014 m = 599986 m = 600016 m = 600047 m = 640016 m = 679984 m = 680018 m = 680053 m = 720018 m = 759982 m = 760020 m = 760059 m = 800020 m = 839980 m = 840022 m = 840065 m = 880022 m = 919978 m = 920024 m = 920071 m = 960024 m = 999976 m = 1000026 m = 1000077 m = 1040026 m = 1079974 m = 1080028 m = 1080083 m = 1120028 m = 1159972 m = 1160030 m = 1160089 m = 1200030 m = 1239970 m = 1240032 m = 1240095 m = 1280032 m = 1319968 m = 1320034 m = 1320101 m = 1360034 m = 1399966 m = 1400036 m = 1400107 m = 1440036 m = 1479964 m = 1480038 m = 1480113 m = 1520038 m = 1559962 m = 1560040 m = 1560119 m = 1600040 m = 1639960 m = 1640042 m = 1640125 m = 1680042 m = 1719958 m = 1720044 m = 1720131 m = 1760044 m = 1799956 m = 1800046 m = 1800137 m = 1840046 m = 1879954 m = 1880048 m = 1880143 m = 1920048 m = 1959952 m = 1960050 m = 1960149 m = 2000050 m = 2039950 m = 2040052 m = 2040155 m = 2080052 m = 2119948 m = 2120054 m = 2120161 m = 2160054 m = 2199946 m = 2200056 m = 2200167 m = 2240056 m = 2279944 m = 2280058 m = 2280173 m = 2320058 m = 2359942 m = 2360060 m = 2360179 m = 2400060 m = 2439940 m = 2440062 m = 2440185 m = 2480062 m = 2519938 m = 2520064 m = 2520191 m = 2560064 m = 2599936 m = 2600066 m = 2600197 m = 2640066 m = 2679934 m = 2680068 m = 2680203 m = 2720068 m = 2759932 m = 2760070 m = 2760209 m = 2800070 m = 2839930 m = 2840072 m = 2840215 m = 2880072 m = 2919928 m = 2920074 m = 2920221 m = 2960074 m = 2999926 m = 3000076 m = 3000227 m = 3040076 m = 3079924 m = 3080078 m = 3080233 m = 3120078 m = 3159922 m = 3160080 m = 3160239 m = 3200080 m = 3239920 m = 3240082 m = 3240245 m = 3280082 m = 3319918 m = 3320084 m = 3320251 m = 3360084 m = 3399916 m = 3400086 m = 3400257 m = 3440086 m = 3479914 m = 3480088 m = 3480263 m = 3520088 m = 3559912 m = 3560090 m = 3560269 m = 3600090 m = 3639910 m = 3640092 m = 3640275 m = 3680092 m = 3719908 m = 3720094 m = 3720281 m = 3760094 m = 3799906 m = 3800096 m = 3800287 m = 3840096 m = 3879904 m = 3880098 m = 3880293 m = 3920098 m = 3959902 m = 3960100 m = 3960299 m = 4000100

8   Pass
n = 1000; y_correct = 500000500; assert(isequal(magic_sum(n),y_correct))

m = 0 m = 1000000 m = 1000002 m = 1000005 m = 2000002 m = 2999998 m = 3000004 m = 3000011 m = 4000004 m = 4999996 m = 5000006 m = 5000017 m = 6000006 m = 6999994 m = 7000008 m = 7000023 m = 8000008 m = 8999992 m = 9000010 m = 9000029 m = 10000010 m = 10999990 m = 11000012 m = 11000035 m = 12000012 m = 12999988 m = 13000014 m = 13000041 m = 14000014 m = 14999986 m = 15000016 m = 15000047 m = 16000016 m = 16999984 m = 17000018 m = 17000053 m = 18000018 m = 18999982 m = 19000020 m = 19000059 m = 20000020 m = 20999980 m = 21000022 m = 21000065 m = 22000022 m = 22999978 m = 23000024 m = 23000071 m = 24000024 m = 24999976 m = 25000026 m = 25000077 m = 26000026 m = 26999974 m = 27000028 m = 27000083 m = 28000028 m = 28999972 m = 29000030 m = 29000089 m = 30000030 m = 30999970 m = 31000032 m = 31000095 m = 32000032 m = 32999968 m = 33000034 m = 33000101 m = 34000034 m = 34999966 m = 35000036 m = 35000107 m = 36000036 m = 36999964 m = 37000038 m = 37000113 m = 38000038 m = 38999962 m = 39000040 m = 39000119 m = 40000040 m = 40999960 m = 41000042 m = 41000125 m = 42000042 m = 42999958 m = 43000044 m = 43000131 m = 44000044 m = 44999956 m = 45000046 m = 45000137 m = 46000046 m = 46999954 m = 47000048 m = 47000143 m = 48000048 m = 48999952 m = 49000050 m = 49000149 m = 50000050 m = 50999950 m = 51000052 m = 51000155 m = 52000052 m = 52999948 m = 53000054 m = 53000161 m = 54000054 m = 54999946 m = 55000056 m = 55000167 m = 56000056 m = 56999944 m = 57000058 m = 57000173 m = 58000058 m = 58999942 m = 59000060 m = 59000179 m = 60000060 m = 60999940 m = 61000062 m = 61000185 m = 62000062 m = 62999938 m = 63000064 m = 63000191 m = 64000064 m = 64999936 m = 65000066 m = 65000197 m = 66000066 m = 66999934 m = 67000068 m = 67000203 m = 68000068 m = 68999932 m = 69000070 m = 69000209 m = 70000070 m = 70999930 m = 71000072 m = 71000215 m = 72000072 m = 72999928 m = 73000074 m = 73000221 m = 74000074 m = 74999926 m = 75000076 m = 75000227 m = 76000076 m = 76999924 m = 77000078 m = 77000233 m = 78000078 m = 78999922 m = 79000080 m = 79000239 m = 80000080 m = 80999920 m = 81000082 m = 81000245 m = 82000082 m = 82999918 m = 83000084 m = 83000251 m = 84000084 m = 84999916 m = 85000086 m = 85000257 m = 86000086 m = 86999914 m = 87000088 m = 87000263 m = 88000088 m = 88999912 m = 89000090 m = 89000269 m = 90000090 m = 90999910 m = 91000092 m = 91000275 m = 92000092 m = 92999908 m = 93000094 m = 93000281 m = 94000094 m = 94999906 m = 95000096 m = 95000287 m = 96000096 m = 96999904 m = 97000098 m = 97000293 m = 98000098 m = 98999902 m = 99000100 m = 99000299 m = 100000100 m = 100999900 m = 101000102 m = 101000305 m = 102000102 m = 102999898 m = 103000104 m = 103000311 m = 104000104 m = 104999896 m = 105000106 m = 105000317 m = 106000106 m = 106999894 m = 107000108 m = 107000323 m = 108000108 m = 108999892 m = 109000110 m = 109000329 m = 110000110 m = 110999890 m = 111000112 m = 111000335 m = 112000112 m = 112999888 m = 113000114 m = 113000341 m = 114000114 m = 114999886 m = 115000116 m = 115000347 m = 116000116 m = 116999884 m = 117000118 m = 117000353 m = 118000118 m = 118999882 m = 119000120 m = 119000359 m = 120000120 m = 120999880 m = 121000122 m = 121000365 m = 122000122 m = 122999878 m = 123000124 m = 123000371 m = 124000124 m = 124999876 m = 125000126 m = 125000377 m = 126000126 m = 126999874 m = 127000128 m = 127000383 m = 128000128 m = 128999872 m = 129000130 m = 129000389 m = 130000130 m = 130999870 m = 131000132 m = 131000395 m = 132000132 m = 132999868 m = 133000134 m = 133000401 m = 134000134 m = 134999866 m = 135000136 m = 135000407 m = 136000136 m = 136999864 m = 137000138 m = 137000413 m = 138000138 m = 138999862 m = 139000140 m = 139000419 m = 140000140 m = 140999860 m = 141000142 m = 141000425 m = 142000142 m = 142999858 m = 143000144 m = 143000431 m = 144000144 m = 144999856 m = 145000146 m = 145000437 m = 146000146 m = 146999854 m = 147000148 m = 147000443 m = 148000148 m = 148999852 m = 149000150 m = 149000449 m = 150000150 m = 150999850 m = 151000152 m = 151000455 m = 152000152 m = 152999848 m = 153000154 m = 153000461 m = 154000154 m = 154999846 m = 155000156 m = 155000467 m = 156000156 m = 156999844 m = 157000158 m = 157000473 m = 158000158 m = 158999842 m = 159000160 m = 159000479 m = 160000160 m = 160999840 m = 161000162 m = 161000485 m = 162000162 m = 162999838 m = 163000164 m = 163000491 m = 164000164 m = 164999836 m = 165000166 m = 165000497 m = 166000166 m = 166999834 m = 167000168 m = 167000503 m = 168000168 m = 168999832 m = 169000170 m = 169000509 m = 170000170 m = 170999830 m = 171000172 m = 171000515 m = 172000172 m = 172999828 m = 173000174 m = 173000521 m = 174000174 m = 174999826 m = 175000176 m = 175000527 m = 176000176 m = 176999824 m = 177000178 m = 177000533 m = 178000178 m = 178999822 m = 179000180 m = 179000539 m = 180000180 m = 180999820 m = 181000182 m = 181000545 m = 182000182 m = 182999818 m = 183000184 m = 183000551 m = 184000184 m = 184999816 m = 185000186 m = 185000557 m = 186000186 m = 186999814 m = 187000188 m = 187000563 m = 188000188 m = 188999812 m = 189000190 m = 189000569 m = 190000190 m = 190999810 m = 191000192 m = 191000575 m = 192000192 m = 192999808 m = 193000194 m = 193000581 m = 194000194 m = 194999806 m = 195000196 m = 195000587 m = 196000196 m = 196999804 m = 197000198 m = 197000593 m = 198000198 m = 198999802 m = 199000200 m = 199000599 m = 200000200 m = 200999800 m = 201000202 m = 201000605 m = 202000202 m = 202999798 m = 203000204 m = 203000611 m = 204000204 m = 204999796 m = 205000206 m = 205000617 m = 206000206 m = 206999794 m = 207000208 m = 207000623 m = 208000208 m = 208999792 m = 209000210 m = 209000629 m = 210000210 m = 210999790 m = 211000212 m = 211000635 m = 212000212 m = 212999788 m = 213000214 m = 213000641 m = 214000214 m = 214999786 m = 215000216 m = 215000647 m = 216000216 m = 216999784 m = 217000218 m = 217000653 m = 218000218 m = 218999782 m = 219000220 m = 219000659 m = 220000220 m = 220999780 m = 221000222 m = 221000665 m = 222000222 m = 222999778 m = 223000224 m = 223000671 m = 224000224 m = 224999776 m = 225000226 m = 225000677 m = 226000226 m = 226999774 m = 227000228 m = 227000683 m = 228000228 m = 228999772 m = 229000230 m = 229000689 m = 230000230 m = 230999770 m = 231000232 m = 231000695 m = 232000232 m = 232999768 m = 233000234 m = 233000701 m = 234000234 m = 234999766 m = 235000236 m = 235000707 m = 236000236 m = 236999764 m = 237000238 m = 237000713 m = 238000238 m = 238999762 m = 239000240 m = 239000719 m = 240000240 m = 240999760 m = 241000242 m = 241000725 m = 242000242 m = 242999758 m = 243000244 m = 243000731 m = 244000244 m = 244999756 m = 245000246 m = 245000737 m = 246000246 m = 246999754 m = 247000248 m = 247000743 m = 248000248 m = 248999752 m = 249000250 m = 249000749 m = ...