Skip to content

[Feat] : Added perfect square #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions Maths/PerfectSquare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
* @description the square root of a number should be an integer
* @see [Perfect square](https://www.cuemath.com/algebra/perfect-squares/)
* @example Perfect square - 9, 16, 25
* @param {num} number
*/


/**
* @param {num} number
*/

export const PerfectSquare = (num : number) => {

let squareRoot:number = Math.sqrt(num)

return Number.isInteger(squareRoot)
}

export const PerfectSquare = (num: number) => {
return Number.isInteger(Math.sqrt(num));
};
22 changes: 8 additions & 14 deletions Maths/test/PerfectSquare.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { PerfectSquare } from "../PerfectSquare";

/**
* Test #1 - 16 expected - true actual - true
* Test #2 - 12 expected - false actual - false
*/

describe("Perfect square", () => {
it("pass the test#1", () => {
expect(PerfectSquare(16)).toBe(true);
})

it("pass the test#2", () => {
expect(PerfectSquare(12)).toBe(false);
})

});
it("pass the test#1", () => {
expect(PerfectSquare(16)).toBe(true);
});

it("pass the test#2", () => {
expect(PerfectSquare(12)).toBe(false);
});
});