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
87 lines
1.4 KiB
Markdown
87 lines
1.4 KiB
Markdown
---
|
|
id: 6a22d77ddf034bc4e35b1d58
|
|
title: "Challenge 351: Pronic Number"
|
|
challengeType: 29
|
|
dashedName: 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`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertIs(is_pronic(6), True)`)
|
|
}})
|
|
```
|
|
|
|
`is_pronic(15)` should return `False`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertIs(is_pronic(15), False)`)
|
|
}})
|
|
```
|
|
|
|
`is_pronic(12)` should return `True`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertIs(is_pronic(12), True)`)
|
|
}})
|
|
```
|
|
|
|
`is_pronic(132)` should return `True`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertIs(is_pronic(132), True)`)
|
|
}})
|
|
```
|
|
|
|
`is_pronic(80)` should return `False`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertIs(is_pronic(80), False)`)
|
|
}})
|
|
```
|
|
|
|
`is_pronic(0)` should return `True`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertIs(is_pronic(0), True)`)
|
|
}})
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```py
|
|
def is_pronic(n):
|
|
|
|
return n
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```py
|
|
def is_pronic(n):
|
|
k = int(n ** 0.5)
|
|
return k * (k + 1) == n
|
|
```
|