Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-124-ordered-radicals.md
2022-10-18 12:59:49 +05:30

2.7 KiB
Raw Blame History

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f3e81000cf542c50fefb 问题 124根数排序 1 301751 problem-124-ordered-radicals

--description--

The radical of n, rad(n), is the product of the distinct prime factors of n. 例如 $504 = 2^3 × 3^2 × 7$,故 $rad(504) = 2 × 3 × 7 = 42$。

如果我们为 1 ≤ n ≤ 10 计算 $rad(n)$,然后按 rad(n) 对它们进行排序,如果部首值相等则按 n 排序,我们得到:

$Unsorted$ $Sorted$
$n$ $rad(n)$ $n$ $rad(n)$ $k$
1 1 1 1 1
2 2 2 2 2
3 3 4 2 3
4 2 8 2 4
5 5 3 3 5
6 6 9 3 6
7 7 5 5 7
8 2 6 6 8
9 3 7 7 9
10 10 10 10 10

E(k) 为已经排序的 n 列中的第 k 个元素;例如,E(4) = 8 且 $E(6) = 9$。 如果 rad(n)1 ≤ n ≤ 100000 排序,找到 $E(10000)$。

--hints--

orderedRadicals() 应该返回 21417

assert.strictEqual(orderedRadicals(), 21417);

--seed--

--seed-contents--

function orderedRadicals() {

  return true;
}

orderedRadicals();

--solutions--

// solution required