We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent af0b0bb commit c7813cbCopy full SHA for c7813cb
1 file changed
Maths/isSquareFree.js
@@ -0,0 +1,13 @@
1
+function isSquareFree(num = 0) {
2
+ for (let i = 2; i < Math.round(Math.sqrt(num) + 1); i++) {
3
+ debugger;
4
+ if (num % Math.pow(i, 2) === 0) return false;
5
+ }
6
+ return true;
7
+}
8
+
9
+const squareFrees = [1, 3, 5, 6, 13, 15, 17, 19, 21, 22, 26, 29, 34, 35, 38];
10
+const notSquareFrees = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40];
11
12
+squareFrees.forEach(s => console.log(_isSquareFree(s)));
13
+notSquareFrees.forEach(n => console.log(_isSquareFree(n)));
0 commit comments