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

Problem writing URL into database
How would I write this into the database?

<?php echo "http://".$_SERVER['SER

Unable to retreve the values from Mysql Query
Hi,

Here is the php code that I have, Query is running properly in phpmyadmin and is resu

Displaying returned XML in another PHP page
I have an online payment form that will return XML given if a payment is successful or declines. I

WHYISNT THIS MYSQL STATEMNT NOT WORKING? (php)
caps because its absolutely rediculous.
i dontunderstand why its not working. there is a column c

Curl & sessions PLS HELP
Hello,

I have a problem with curl and sessions and i will try to explain the best i could.

php mysql query from input textbox
Hi,

I have a text box, in that i have given the mysql query. I can able to get the query in v

$GPRMC and NMEA how to extract from report
Hi There,

Im a little bi lost and not sure where to start with this one, ive got a small gps

EXplanation help
Hey all,

I am still fairly new to PHP programming and I am trying to put together a page wher

form variables from database help.
Hi all,

I would like to have a form that gives you options based on the results of an mysql q

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

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