feat(challenges): Updated project euler problem (#15754)
added more assertion and tweaked the task feat(challenges): Added solution for project euler Added solution for project euler problem 21pull/18182/head
parent
74f35d6999
commit
1e2364bb74
|
@ -672,23 +672,26 @@
|
|||
"type": "bonfire",
|
||||
"title": "Problem 21: Amicable numbers",
|
||||
"tests": [
|
||||
"assert.strictEqual(euler21(), 31626, 'message: <code>euler21()</code> should return 31626.');"
|
||||
"assert.strictEqual(sumAmicableNum(1000), 504, 'message: \u003ccode\u003esumAmicableNum(1000)\u003c/code\u003e should return 504.');",
|
||||
"assert.strictEqual(sumAmicableNum(2000), 2898, 'message: \u003ccode\u003esumAmicableNum(2000)\u003c/code\u003e should return 2898.');",
|
||||
"assert.strictEqual(sumAmicableNum(5000), 8442, 'message: \u003ccode\u003esumAmicableNum(5000)\u003c/code\u003e should return 8442.');",
|
||||
"assert.strictEqual(sumAmicableNum(10000), 31626, 'message: \u003ccode\u003esumAmicableNum(10000)\u003c/code\u003e should return 31626.');"
|
||||
],
|
||||
"solutions": [],
|
||||
"translations": {},
|
||||
"challengeSeed": [
|
||||
"function euler21() {",
|
||||
"function sumAmicableNum(n) {",
|
||||
" // Good luck!",
|
||||
" return true;",
|
||||
" return n;",
|
||||
"}",
|
||||
"",
|
||||
"euler21();"
|
||||
"sumAmicableNum(10000);"
|
||||
],
|
||||
"description": [
|
||||
"Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).",
|
||||
"If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.",
|
||||
"For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.",
|
||||
"Evaluate the sum of all the amicable numbers under 10000."
|
||||
"Evaluate the sum of all the amicable numbers under n."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue