dbillings Posted April 18, 2008 Share Posted April 18, 2008 Does this make sense to anyone? Apparently the ... means that other statements are there they are just omitted, it's a head scratcher for me. Assuming that n is an integer argument, write a function to compute f(n) where f(n) = 1 + 2 + 3 + … + n Then, write a function to compute g(n) where g(n) = f(1) + f(2) + … f(n) Link to comment https://forums.phpfreaks.com/topic/101645-possible-recursion-scenario/ Share on other sites More sharing options...
Zane Posted April 18, 2008 Share Posted April 18, 2008 F of n = Increment by 1 starting at one until you reach n G of n = Increment by f(1) starting at f(1) until you reach f(n). seems pretty straight forward to me Link to comment https://forums.phpfreaks.com/topic/101645-possible-recursion-scenario/#findComment-520058 Share on other sites More sharing options...
dbillings Posted April 18, 2008 Author Share Posted April 18, 2008 what do you mean f of n and g of n? Link to comment https://forums.phpfreaks.com/topic/101645-possible-recursion-scenario/#findComment-520067 Share on other sites More sharing options...
Zane Posted April 18, 2008 Share Posted April 18, 2008 F of n is the same as f(n) and f(n) is the same as say..... myNewFunction($parameter) technically you'd call that myNewFunction of $parameter Link to comment https://forums.phpfreaks.com/topic/101645-possible-recursion-scenario/#findComment-520071 Share on other sites More sharing options...
dbillings Posted April 18, 2008 Author Share Posted April 18, 2008 Thanks Zanus I appreciate the help. I get the concept. Link to comment https://forums.phpfreaks.com/topic/101645-possible-recursion-scenario/#findComment-520073 Share on other sites More sharing options...
sasa Posted April 18, 2008 Share Posted April 18, 2008 <?php function f_and_g($n){ while ($i <$n){ $i++; $f += $i; $g += $f; } return array('f' => $f, 'g' => $g); } $r = f_and_g(3); print_r($r); ?> Link to comment https://forums.phpfreaks.com/topic/101645-possible-recursion-scenario/#findComment-520078 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.