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

Will this protect from mysql injection?
I do not want anything like DROP TABLE to work or any type of coding..

Heres my code.. is it

listing help
Hi,

at first, great new design!!! I like it,

i got a problem,

I want to list so

pull content
I have an existing page, domain/adverts.php which has a good PR. I've just rebuilt my site and the n

Effort Estimation Template for Steady State Support
Hi Everyone,

Is there any SAP provided template/format for system change and enhancements

Saas with SAP R/3
hi experts,

Is SaaS offer available in SAP? for SAP R/3? from where i can get the info a

Array question
Does anyone know how to create a program that takes the $ amount for 8 different departments and gi

MYSQL gen help
This is my Mysql gen. can anyone tell me why this echos

MID(networkset.networkid, 3, 3) AS &q

Target costs on Process orders not calculating
Hi All,

We have released standard costs for all the materials. We have also done Goods r

Filtering an Array Based on Value
I have a very simple script set up that pulls data from a database and is output using this code:

convert static html data into dynamic
hi all

i need to convert a website which has static above 2000 articles into dynamic and add

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