Find The Square Root Of A Number In PHP

What we are going to see through this article is Find The Square Root Of A Number In PHP. If a number is multiplied by itself (n * n), the final number will be the square of that number, and finding the square root of a number is the reverse function of classifying the number. If x is the square root of y, it can be expressed as:

Formula:

r = n^(1/2)

where:

r = root

n = number

Find The Square Root Of A Number In PHP

Find the Square Root of a Number in PHP

This is an example program to find the square root of a number in PHP program here.

<?php
echo(sqrt(2) . "<br>");
echo(sqrt(25) . "<br>");
echo(sqrt(100) . "<br>");
echo(sqrt(0.169) . "<br>");
echo(sqrt(-16));
?>

Read Also: How To Initialize An Array In PHP

Output

sqrt(2) = 1.4142135623731
sqrt(25) = 5
sqrt(100) = 10
sqrt(0.169) = 0.41109609582189
sqrt(-16) = NAN

Final Words

What we learned through this article is Find The Square Root Of A Number In PHP. Also if you have any doubts please leave a comment via the comment box. And we ask that you benefit everyone who shared this article with your friends.

Leave a Comment