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

Simple program to copy files between two computers over the web
I use logmein free and often need to move files between my two computers. Generally, I move the file

PHP form authentication
Hi guys,

what am trying to achieve is this: Whenever a user tries to login to my website, an

Optimize Code
Just started getting into the use of cookies. The following code will redirect users to a set URL s

TimeZoneOffset
Hello,

Please i need your help. I have a system that users can use to punch in and out. This

Dynamic Array using glob?
Is there an easier way to do this?

I am trying to get create a dyamic array based on files wi

passing data from one page to another
hey guys
i have the follwoing code to get information from one page and place on another:

Code working in IE but not FireFox
I created a dynamic navigation list for my website based off of a table in my database. The code is

phpmailer class & pop.gmail.com?
Code: <?php
$mail->IsSMTP();
$mail->Host = "pop.gmail.com";

CODE NOT WORKING
Code: [Select]<?php
//include shared codes

include '../lib/common.php';
include

Help with writing "$" with fopen
I just can't get my syntax correct. Could someone help me please? I am trying to write a connect fil

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