dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.3 KiB
1.3 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 681cb1b0dab50c87ddb2e51a | Challenge 9: Sum of Squares | 29 | challenge-9 |
--description--
Given a positive integer up to 1,000, return the sum of all the integers squared from 1 up to the number.
--hints--
sum_of_squares(5) should return 55.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_squares(5), 55)`)
}})
sum_of_squares(10) should return 385.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_squares(10), 385)`)
}})
sum_of_squares(25) should return 5525.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_squares(25), 5525)`)
}})
sum_of_squares(500) should return 41791750.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_squares(500), 41791750)`)
}})
sum_of_squares(1000) should return 333833500.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_squares(1000), 333833500)`)
}})
--seed--
--seed-contents--
def sum_of_squares(n):
return n
--solutions--
def sum_of_squares(n):
sum = ((n)*(n+1)*(2*n+1))//6
return sum