Jump to content

My Recursive Function


Recommended Posts

I have made a recursive function -

function croncount ( $sec, $count ) {	if ( $sec > 299 ) {			$count = $count + 1;				$sofar =  $count * 300;				$poo = $sec - $sofar;				croncount ( $poo, $count );		} else {			return "$count";		}}

It is supposed to work out how many lots of 300 there are in the number ($sec).But when I print out this function, nothing is returned?What have I done wrong?I set $count to "0" when calling the function, so it starts from "0".EDIT: Nevermind just found the problem, I wasn't returning the function in the first IF bit.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...