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.4 KiB
1.4 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 6a22d77ddf034bc4e35b1d58 | Challenge 351: Pronic Number | 29 | challenge-351 |
--description--
Given a number, determine whether it is a pronic number.
A pronic number is the product of two consecutive integers. For example, 6 is pronic because 2 * 3 = 6.
--hints--
is_pronic(6) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_pronic(6), True)`)
}})
is_pronic(15) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_pronic(15), False)`)
}})
is_pronic(12) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_pronic(12), True)`)
}})
is_pronic(132) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_pronic(132), True)`)
}})
is_pronic(80) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_pronic(80), False)`)
}})
is_pronic(0) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_pronic(0), True)`)
}})
--seed--
--seed-contents--
def is_pronic(n):
return n
--solutions--
def is_pronic(n):
k = int(n ** 0.5)
return k * (k + 1) == n