First root of a number


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I can't find any function in php to give me the first root of a number.
Is there any built-in function for it?

For example:
81 => 3
9 => 3
64 => 2
256 => 2

I wrote this function to get it, But it seems sqrt always return a float.

Code: <?php
function getRoot($num)
{
if (is_int(sqrt($num))) // (strpos(sqrt($num), '.'))
$num = sqrt($num);

return $num;
}
?>

Any idea?

No comments posted yet

Your Answer:

Login to answer
140 Like 6 Dislike
Previous forums Next forums
Other forums

Remove values in array2 from array1
I have two arrays.

Array 1 is where the array key holds various different numbers. For exampl

path to include folder
Hi everyone,

When I'm testing locally, I have to add the name of the site folder as part of t

PHP Upload issue
Hi guys,

I have stumble across an interesting issue with my script and is doing my head in.

How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor

How to add advertisment on top of videos
Hello,
I was told that i should find the answer for this problem in this forums.
I searched a

How to show more than 1 users with this code...
Hello,
i have a table that shows users only if I, as Administrator, want to be shown. But its sho

need help with date function
i have following form for date

Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01

Multiple includes losing variables
Hey all,

just starting out w php and ran into a problem pretty quickly. I'm
including seve

sapgui f4 help last search
I know this has to be simople. One user (maybe more) does not have the "last search saved" from the

i want run some web server under the ip sharer
hello i want run some web server under the ip sharer
my ip is floating ip but it doesnt matter

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash