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?
Did you know?Explore Trending and Topic pages for more stories like this.

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

Breaking results into week blocks
I have a set of dates (and times), which are returned from a mySQL query.

These usually span

Help? Need help on project with templates involving mysql and php.
I'm having a hard time explaining what I want but basically here is what I have in place:

-Da

SESSION question
I am building an application , a directory for auctions.
For SEO i made a script which copies a p

error with opendir
when i do this

if ($handle = opendir($dir)) {
while (false !== ($file = readdir($han

PHP IMAGE UPLOAD SCRIPT
Hi for the last week i have been looking for scripts that will upload a photo to a certain folder wh

Parse Error
Hi Guys,

I have a function in my class which returns a string link variable. The problem is i

The IE or FF detector
Hello Friends,

Problem of today ( we seek for php help ) as following ,

we know all th

Clean URLs
Hi I was wandering if anyone has ever implemented URLs on their PHP run website using URLS like wiki

Execure stored procedure on a timer
Can someone tell me an easier way to execute a stored procedure on a timer? I am using Oracle 10g R

About imagecopyresampled()
Hello,

I am looking to use this function to resize parts of an image to a fixed thumbnail siz

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