Return to Snippet

Revision: 41893
at February 24, 2011 10:23 by iamdezzy


Updated Code
<?php 
$number = 1;
$lastnumber = 2800;
set_time_limit(0);
	function find($x){
		settype($x, "string");
		$u=strlen($x);
			if($u == 1){
				return $x;
			}
		return bcpow($x[$u-1],$u) + find(floor($x/10));
	}
	
	for($a=1;$a<$lastnumber;$a++){
		$result = find($number);
			if($result == $number){
				echo $number."<br/>";
			}
		$number++;
	}
?>

Revision: 41892
at February 24, 2011 10:19 by iamdezzy


Initial Code
<?php 
$number = 1;
$lastnumber = 2800;
set_time_limit(0);
	function find($x){
		settype($x, "string");
		$u=strlen($x);
			if($u == 1){
				return $x;
			}
		return bcpow($x[$u-1],$u) + find(floor($x/10));
	}
	
	for($a=1;$a<$lastnumber;$a++){
		$result = find($u);
			if($result == $u){
				echo $u."<br/>";
			}
		$u++;
	}
?>

Initial URL

                                

Initial Description
I'm just trying

Initial Title
Function for Finding Narcissistic Numbers

Initial Tags
math

Initial Language
PHP