Definitions
- A perfect square is an integer which can be expressed as the square of another integer. For example,
36
is a perfect square because6^2 = 36
. - A squarefree number is an integer which is not divisible by any perfect square, except by
1
. For example,10
is a squarefree number. However,12
is not a squarefree number, because12
is divisible by4
and4
is a perfect square.
Task
Given a positive integer n
, output the largest squarefree number which divides n
.
Testcases
n output
1 1
2 2
3 3
4 2
5 5
6 6
7 7
8 2
9 3
10 10
11 11
12 6
13 13
14 14
15 15
16 2
17 17
18 6
19 19
20 10
21 21
22 22
23 23
24 6
25 5
26 26
27 3
28 14
29 29
30 30
31 31
32 2
33 33
34 34
35 35
36 6
37 37
38 38
39 39
40 10
41 41
42 42
43 43
44 22
45 15
46 46
47 47
48 6
49 7
50 10
Scoring
This is code-golf. Shortest answer in bytes wins.
Standard loopholes apply.