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

how do I show what a user have selected from a checkbox?
From my code below, how would i show which check boxes have been checked and which radio buttons sel

Record count of entire database
Does anyone know if there is a way to obtain the number of records in each table of the database usi

Sql and php order list script problems
Hi im having a few problems with trying to get the coding right on a orders list ive done (or trying

Multiple includes losing variables
Hey all,

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

HTML form problem
Ive made a form to that i want to send to my email via PHP. but when it send only the name's etc sen

fwrite error
Hi All,
Does anyone know what is causing the error in this code?

Code: <?
$error

Windows Authentication
I have a website which is windows authenticated.
now i want something more on this application.<

Locking mysql tables with php
Hi

BACKGROUND:
I have multiple instances of the same php script running in a WAMP environ

What makes a script your own?
If someone finds a login script online, and changes some variable names around and some other minor

Changing files over
Just thought I'd start with the new forums looking really nice .

Ok basically I've made this

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