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

Return X values where an ID number doesnt matter
Well as for subject heading, thats the best i could think of.

Currently im having a problem w

Pspell with my own dictionary
Hello!
I've tested two cases using pspell functions.
1)
Code: $dictionary_link = pspell_new

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:
Parse error: syntax error, unexpect

links using header()
Hi All

I'm not sure where to ask for help on this but I hope someone can offer some. I'm at

Converting RGB values to HEX
Code: <?PHP

$file_handle = fopen("colors/rgb.csv", "r");

wh

phpMailer will not connect using SMTP
I am trying to use phpMailer with smtp:

Code: [Select]$mailer = new PHPMailer();
$mailer-&

Libraries in C++
Hi all,

I have two libraries. one is based targeted on linux platform and uses another li

Query output more than expected
$query=mysql_query("SELECT * FROM players, communities, divisions WHERE dob BETWEEN '{$start_da

single values into sql field
i have a form which i want the user to able to select multiple answers. But i want the answers to be

user administration
Dear @all,

what I have to do to set the user defaults for new users. At the moment I woul

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