Cody

Problem 1087. Magic is simple (for beginners)

Solution 2105774

Submitted on 26 Jan 2020 by stozaki
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 = 8 m = 11 m = 15

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

m = 17 m = 40 m = 44 m = 54 m = 65

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

m = 30 m = 68 m = 114 m = 119 m = 132 m = 153 m = 175

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

m = 64 m = 73 m = 90 m = 130 m = 162 m = 203 m = 252 m = 260

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

m = 400 m = 421 m = 462 m = 802 m = 1122 m = 1223 m = 1344 m = 1604 m = 1844 m = 2025 m = 2226 m = 2406 m = 2566 m = 2827 m = 3108 m = 3208 m = 3288 m = 3629 m = 3990 m = 4010

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

m = 10000 m = 10101 m = 10302 m = 20002 m = 29602 m = 30103 m = 30704 m = 40004 m = 49204 m = 50105 m = 51106 m = 60006 m = 68806 m = 70107 m = 71508 m = 80008 m = 88408 m = 90109 m = 91910 m = 100010 m = 108010 m = 110111 m = 112312 m = 120012 m = 127612 m = 130113 m = 132714 m = 140014 m = 147214 m = 150115 m = 153116 m = 160016 m = 166816 m = 170117 m = 173518 m = 180018 m = 186418 m = 190119 m = 193920 m = 200020 m = 206020 m = 210121 m = 214322 m = 220022 m = 225622 m = 230123 m = 234724 m = 240024 m = 245224 m = 250125 m = 255126 m = 260026 m = 264826 m = 270127 m = 275528 m = 280028 m = 284428 m = 290129 m = 295930 m = 300030 m = 304030 m = 310131 m = 316332 m = 320032 m = 323632 m = 330133 m = 336734 m = 340034 m = 343234 m = 350135 m = 357136 m = 360036 m = 362836 m = 370137 m = 377538 m = 380038 m = 382438 m = 390139 m = 397940 m = 400040 m = 402040 m = 410141 m = 418342 m = 420042 m = 421642 m = 430143 m = 438744 m = 440044 m = 441244 m = 450145 m = 459146 m = 460046 m = 460846 m = 470147 m = 479548 m = 480048 m = 480448 m = 490149 m = 499950 m = 500050

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

m = 40000 m = 40201 m = 40602 m = 80002 m = 119202 m = 120203 m = 121404 m = 160004 m = 198404 m = 200205 m = 202206 m = 240006 m = 277606 m = 280207 m = 283008 m = 320008 m = 356808 m = 360209 m = 363810 m = 400010 m = 436010 m = 440211 m = 444612 m = 480012 m = 515212 m = 520213 m = 525414 m = 560014 m = 594414 m = 600215 m = 606216 m = 640016 m = 673616 m = 680217 m = 687018 m = 720018 m = 752818 m = 760219 m = 767820 m = 800020 m = 832020 m = 840221 m = 848622 m = 880022 m = 911222 m = 920223 m = 929424 m = 960024 m = 990424 m = 1000225 m = 1010226 m = 1040026 m = 1069626 m = 1080227 m = 1091028 m = 1120028 m = 1148828 m = 1160229 m = 1171830 m = 1200030 m = 1228030 m = 1240231 m = 1252632 m = 1280032 m = 1307232 m = 1320233 m = 1333434 m = 1360034 m = 1386434 m = 1400235 m = 1414236 m = 1440036 m = 1465636 m = 1480237 m = 1495038 m = 1520038 m = 1544838 m = 1560239 m = 1575840 m = 1600040 m = 1624040 m = 1640241 m = 1656642 m = 1680042 m = 1703242 m = 1720243 m = 1737444 m = 1760044 m = 1782444 m = 1800245 m = 1818246 m = 1840046 m = 1861646 m = 1880247 m = 1899048 m = 1920048 m = 1940848 m = 1960249 m = 1979850 m = 2000050 m = 2020050 m = 2040251 m = 2060652 m = 2080052 m = 2099252 m = 2120253 m = 2141454 m = 2160054 m = 2178454 m = 2200255 m = 2222256 m = 2240056 m = 2257656 m = 2280257 m = 2303058 m = 2320058 m = 2336858 m = 2360259 m = 2383860 m = 2400060 m = 2416060 m = 2440261 m = 2464662 m = 2480062 m = 2495262 m = 2520263 m = 2545464 m = 2560064 m = 2574464 m = 2600265 m = 2626266 m = 2640066 m = 2653666 m = 2680267 m = 2707068 m = 2720068 m = 2732868 m = 2760269 m = 2787870 m = 2800070 m = 2812070 m = 2840271 m = 2868672 m = 2880072 m = 2891272 m = 2920273 m = 2949474 m = 2960074 m = 2970474 m = 3000275 m = 3030276 m = 3040076 m = 3049676 m = 3080277 m = 3111078 m = 3120078 m = 3128878 m = 3160279 m = 3191880 m = 3200080 m = 3208080 m = 3240281 m = 3272682 m = 3280082 m = 3287282 m = 3320283 m = 3353484 m = 3360084 m = 3366484 m = 3400285 m = 3434286 m = 3440086 m = 3445686 m = 3480287 m = 3515088 m = 3520088 m = 3524888 m = 3560289 m = 3595890 m = 3600090 m = 3604090 m = 3640291 m = 3676692 m = 3680092 m = 3683292 m = 3720293 m = 3757494 m = 3760094 m = 3762494 m = 3800295 m = 3838296 m = 3840096 m = 3841696 m = 3880297 m = 3919098 m = 3920098 m = 3920898 m = 3960299 m = 3999900 m = 4000100

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

m = 1000000 m = 1001001 m = 1003002 m = 2000002 m = 2996002 m = 3001003 m = 3007004 m = 4000004 m = 4992004 m = 5001005 m = 5011006 m = 6000006 m = 6988006 m = 7001007 m = 7015008 m = 8000008 m = 8984008 m = 9001009 m = 9019010 m = 10000010 m = 10980010 m = 11001011 m = 11023012 m = 12000012 m = 12976012 m = 13001013 m = 13027014 m = 14000014 m = 14972014 m = 15001015 m = 15031016 m = 16000016 m = 16968016 m = 17001017 m = 17035018 m = 18000018 m = 18964018 m = 19001019 m = 19039020 m = 20000020 m = 20960020 m = 21001021 m = 21043022 m = 22000022 m = 22956022 m = 23001023 m = 23047024 m = 24000024 m = 24952024 m = 25001025 m = 25051026 m = 26000026 m = 26948026 m = 27001027 m = 27055028 m = 28000028 m = 28944028 m = 29001029 m = 29059030 m = 30000030 m = 30940030 m = 31001031 m = 31063032 m = 32000032 m = 32936032 m = 33001033 m = 33067034 m = 34000034 m = 34932034 m = 35001035 m = 35071036 m = 36000036 m = 36928036 m = 37001037 m = 37075038 m = 38000038 m = 38924038 m = 39001039 m = 39079040 m = 40000040 m = 40920040 m = 41001041 m = 41083042 m = 42000042 m = 42916042 m = 43001043 m = 43087044 m = 44000044 m = 44912044 m = 45001045 m = 45091046 m = 46000046 m = 46908046 m = 47001047 m = 47095048 m = 48000048 m = 48904048 m = 49001049 m = 49099050 m = 50000050 m = 50900050 m = 51001051 m = 51103052 m = 52000052 m = 52896052 m = 53001053 m = 53107054 m = 54000054 m = 54892054 m = 55001055 m = 55111056 m = 56000056 m = 56888056 m = 57001057 m = 57115058 m = 58000058 m = 58884058 m = 59001059 m = 59119060 m = 60000060 m = 60880060 m = 61001061 m = 61123062 m = 62000062 m = 62876062 m = 63001063 m = 63127064 m = 64000064 m = 64872064 m = 65001065 m = 65131066 m = 66000066 m = 66868066 m = 67001067 m = 67135068 m = 68000068 m = 68864068 m = 69001069 m = 69139070 m = 70000070 m = 70860070 m = 71001071 m = 71143072 m = 72000072 m = 72856072 m = 73001073 m = 73147074 m = 74000074 m = 74852074 m = 75001075 m = 75151076 m = 76000076 m = 76848076 m = 77001077 m = 77155078 m = 78000078 m = 78844078 m = 79001079 m = 79159080 m = 80000080 m = 80840080 m = 81001081 m = 81163082 m = 82000082 m = 82836082 m = 83001083 m = 83167084 m = 84000084 m = 84832084 m = 85001085 m = 85171086 m = 86000086 m = 86828086 m = 87001087 m = 87175088 m = 88000088 m = 88824088 m = 89001089 m = 89179090 m = 90000090 m = 90820090 m = 91001091 m = 91183092 m = 92000092 m = 92816092 m = 93001093 m = 93187094 m = 94000094 m = 94812094 m = 95001095 m = 95191096 m = 96000096 m = 96808096 m = 97001097 m = 97195098 m = 98000098 m = 98804098 m = 99001099 m = 99199100 m = 100000100 m = 100800100 m = 101001101 m = 101203102 m = 102000102 m = 102796102 m = 103001103 m = 103207104 m = 104000104 m = 104792104 m = 105001105 m = 105211106 m = 106000106 m = 106788106 m = 107001107 m = 107215108 m = 108000108 m = 108784108 m = 109001109 m = 109219110 m = 110000110 m = 110780110 m = 111001111 m = 111223112 m = 112000112 m = 112776112 m = 113001113 m = 113227114 m = 114000114 m = 114772114 m = 115001115 m = 115231116 m = 116000116 m = 116768116 m = 117001117 m = 117235118 m = 118000118 m = 118764118 m = 119001119 m = 119239120 m = 120000120 m = 120760120 m = 121001121 m = 121243122 m = 122000122 m = 122756122 m = 123001123 m = 123247124 m = 124000124 m = 124752124 m = 125001125 m = 125251126 m = 126000126 m = 126748126 m = 127001127 m = 127255128 m = 128000128 m = 128744128 m = 129001129 m = 129259130 m = 130000130 m = 130740130 m = 131001131 m = 131263132 m = 132000132 m = 132736132 m = 133001133 m = 133267134 m = 134000134 m = 134732134 m = 135001135 m = 135271136 m = 136000136 m = 136728136 m = 137001137 m = 137275138 m = 138000138 m = 138724138 m = 139001139 m = 139279140 m = 140000140 m = 140720140 m = 141001141 m = 141283142 m = 142000142 m = 142716142 m = 143001143 m = 143287144 m = 144000144 m = 144712144 m = 145001145 m = 145291146 m = 146000146 m = 146708146 m = 147001147 m = 147295148 m = 148000148 m = 148704148 m = 149001149 m = 149299150 m = 150000150 m = 150700150 m = 151001151 m = 151303152 m = 152000152 m = 152696152 m = 153001153 m = 153307154 m = 154000154 m = 154692154 m = 155001155 m = 155311156 m = 156000156 m = 156688156 m = 157001157 m = 157315158 m = 158000158 m = 158684158 m = 159001159 m = 159319160 m = 160000160 m = 160680160 m = 161001161 m = 161323162 m = 162000162 m = 162676162 m = 163001163 m = 163327164 m = 164000164 m = 164672164 m = 165001165 m = 165331166 m = 166000166 m = 166668166 m = 167001167 m = 167335168 m = 168000168 m = 168664168 m = 169001169 m = 169339170 m = 170000170 m = 170660170 m = 171001171 m = 171343172 m = 172000172 m = 172656172 m = 173001173 m = 173347174 m = 174000174 m = 174652174 m = 175001175 m = 175351176 m = 176000176 m = 176648176 m = 177001177 m = 177355178 m = 178000178 m = 178644178 m = 179001179 m = 179359180 m = 180000180 m = 180640180 m = 181001181 m = 181363182 m = 182000182 m = 182636182 m = 183001183 m = 183367184 m = 184000184 m = 184632184 m = 185001185 m = 185371186 m = 186000186 m = 186628186 m = 187001187 m = 187375188 m = 188000188 m = 188624188 m = 189001189 m = 189379190 m = 190000190 m = 190620190 m = 191001191 m = 191383192 m = 192000192 m = 192616192 m = 193001193 m = 193387194 m = 194000194 m = 194612194 m = 195001195 m = 195391196 m = 196000196 m = 196608196 m = 197001197 m = 197395198 m = 198000198 m = 198604198 m = 199001199 m = 199399200 m = 200000200 m = 200600200 m = 201001201 m = 201403202 m = 202000202 m = 202596202 m = 203001203 m = 203407204 m = 204000204 m = 204592204 m = 205001205 m = 205411206 m = 206000206 m = 206588206 m = 207001207 m = 207415208 m = 208000208 m = 208584208 m = 209001209 m = 209419210 m = 210000210 m = 210580210 m = 211001211 m = 211423212 m = 212000212 m = 212576212 m = 213001213 m = 213427214 m = 214000214 m = 214572214 m = 215001215 m = 215431216 m = 216000216 m = 216568216 m = 217001217 m = 217435218 m = 218000218 m = 218564218 m = 219001219 m = 219439220 m = 220000220 m = 220560220 m = 221001221 m = 221443222 m = 222000222 m = 222556222 m = 223001223 m = 223447224 m = 224000224 m = 224552224 m = 225001225 m = 225451226 m = 226000226 m = 226548226 m = 227001227 m = 227455228 m = 228000228 m = 228544228 m = 229001229 m = 229459230 m = 230000230 m = 230540230 m = 231001231 m = 231463232 m = 232000232 m = 232536232 m = 233001233 m = 233467234 m = 234000234 m = 234532234 m = 235001235 m = 235471236 m = 236000236 m = 236528236 m = 237001237 m = 237475238 m = 238000238 m = 238524238 m = 239001239 m = 239479240 m = 240000240 m = 240520240 m = 241001241 m = 241483242 m = 242000242 m = 242516242 m = 243001243 m = 243487244 m = 244000244 m = 244512244 m = 245001245 m = 245491246 m = 246000246 m = 246508246 m = 247001247 m = 247495248 m = 248000248 m = 248504248 m = 249001249 m = 249499250 m = 250000250 ...

Suggested Problems

More from this Author43

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!