Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6a22d77ddf034bc4e35b1d58.md
T
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

71 lines
986 B
Markdown

---
id: 6a22d77ddf034bc4e35b1d58
title: "Challenge 351: Pronic Number"
challengeType: 28
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--
`isPronic(6)` should return `true`.
```js
assert.isTrue(isPronic(6));
```
`isPronic(15)` should return `false`.
```js
assert.isFalse(isPronic(15));
```
`isPronic(12)` should return `true`.
```js
assert.isTrue(isPronic(12));
```
`isPronic(132)` should return `true`.
```js
assert.isTrue(isPronic(132));
```
`isPronic(80)` should return `false`.
```js
assert.isFalse(isPronic(80));
```
`isPronic(0)` should return `true`.
```js
assert.isTrue(isPronic(0));
```
# --seed--
## --seed-contents--
```js
function isPronic(n) {
return n;
}
```
# --solutions--
```js
function isPronic(n) {
const k = Math.floor(Math.sqrt(n));
return k * (k + 1) === n;
}
```