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

Post, not working, please help
The error is:
Method Not Allowed
The requested method POST is not allowed for the URL /student

Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q

Retrieving innerHTML with cURL?
Hey all (sorry I know I'm a leecher, but I soon won't be. This is my first PHP project, but not my l

foreach help.
Hello all,

First time I'm attempting to use a foreach statement and was just wondering if my

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

CRM?
I think that's what they're called. Customer Management System? Anyway. Is there any good free ones

upload only text files
hi guys i want to upload only text like like (pdf,note pad and ofiice files) so can any one please t

DBCA Templates
Hi all,

I'm working on creating a template for DBCA, but can't find any documentation on the

If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and th

Hom to make one url to open together with another url
I have a chat, which i want to be opened, as soon as the users login to the site. As it is now, when

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