Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Perfect Square Number in MATLAB

Perfect Square number:

In mathematics, a square number or perfect square is an integer that is the square of an integer.
Example :25(square of 5) , 36(square of 6) etc.

If you want to know more on Perfect number , check the below link:

Algorithm to check perfect number:

Step 1:

Square root the number

Step 2:

Now you have to check whether that number is integer or decimal.

To do so , take ceil or round operation & check that the square root number & the number after performing ceil/round operation on the square root number are same or not.

Step 3:

If both are same , then " YES, the number is perfect square" or else "No , the number is not perfect square number".

MATLAB code:

x=input('Enter the number:');




disp('Yes, the number is perfect square number');


disp('No , the number is not a perfect square number');


Explanation of the code:

You can use same algorithm in JAVA also , just syntax will


Java Program:
import java.util.Scanner;

import java.lang.Math;

class Perfect


public static void main(String args[])


Scanner obj=new Scanner(;

System.out.println("Enter the number:");

int m=obj.nextInt();

double z=Math.sqrt(m);

double y=Math.ceil(z);



System.out.println("YES, the number is perfect square





System.out.println("No, the number is not a perfect square number");



} Reference Video:

Difference between ceil & round function :

No comments