Post History
An integer is called square-free if it is not a multiple of a perfect square other than 1. For example, 42 is square-free, but 44 is not because it is a multiple of the perfect square 4 = 2². Your...
#2: Post edited
- An integer is called square-free if it is not a multiple of a perfect square other than 1. For example, 42 is square-free, but 44 is not because it is a multiple of the perfect square 4 = 2².
- Your task is to write a program or function that takes a positive integer, and returns a truthy value if the integer is square-free and a falsey value otherwise.
- This is code golf, the shortest code wins.
- An integer is called square-free if it is not a multiple of a perfect square other than 1. For example, 42 is square-free, but 44 is not because it is a multiple of the perfect square 4 = 2².
- Your task is to write a program or function that takes a positive integer, and returns a truthy value if the integer is square-free and a falsey value otherwise.
- This is code golf, the shortest code wins.
- The square-free numbers are OEIS sequence <a href="https://oeis.org/A005117">A005117</a> (thanks to [Razetime][Razetime] for pointing this out).
- Some test cases:
- ```
- 1 true
- 2 true
- 3 true
- 4 false
- 5 true
- 6 true
- 7 true
- 8 false
- 9 false
- 10 true
- 12 false
- 14 true
- 16 false
- 18 false
- 20 false
- 30 true
- 40 false
- 50 false
- 100 false
- 110 true
- 111 true
- ```
- [Razetime]: https://codegolf.codidact.com/users/53310
#1: Initial revision
Determine whether an integer is square-free
An integer is called square-free if it is not a multiple of a perfect square other than 1. For example, 42 is square-free, but 44 is not because it is a multiple of the perfect square 4 = 2². Your task is to write a program or function that takes a positive integer, and returns a truthy value if the integer is square-free and a falsey value otherwise. This is code golf, the shortest code wins.