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

array & querys help/advice.
Ok so here goes , I have a mysql database and basically here's what I need to do.

// foreach

Working with Dates, help.
Sooo to make a long story short, here's what im trying to accomplish.

I need to create a drop

question about n
I was looking at some of the things you could do with php and one of the things I have tried is n.<

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

php call servlet
I have done a php backup application .
So there is a form that user pick some files to zip and d

Stopping page post back
I have few literal contriols in my page and a repeater too. But inspite of using update panel, postb

Filtering Tables
Hello Thanks for any help any one can give Im very new to PHP..

I need to pull data for clien

HOW to get the bind variables list.
I've the following problem : I've some SQL queries stored in my DB as VARCHAR2 values.
I need t

Simple image grab script.
I was wondering if it was possible and if anyone knew how to make a simple php script that looks at

Why will this program not run if the variables are not global?
Hey guys I have a kind of perplexing situation that is probably simple, but I can't seem to understa

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