- 197
- 10
as stated above I need some help finding out how to develop a factorial calculator using c#... if someone could pm me thatd be great.. dont wanna get in trouble in case someone thinks this is for homework...
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Originally Posted by omgitswes
C# is like Java right?
Originally Posted by omgitswes
C# is like Java right?
That and classes in C can inherit from multiple classes, versus Java where you have to utilize interfaces to make a class inherit functionality from more than one class. Plus a few other key things.Originally Posted by LuckyLuchiano
Originally Posted by omgitswes
C# is like Java right?
all that stuff is the same just diff syntax.
That and classes in C can inherit from multiple classes, versus Java where you have to utilize interfaces to make a class inherit functionality from more than one class. Plus a few other key things.Originally Posted by LuckyLuchiano
Originally Posted by omgitswes
C# is like Java right?
all that stuff is the same just diff syntax.
function factorial($number){
$result = 1
if($number < 0){ // Only works with positive number;
$result = -1; // Use -1 to display an error message or something
}elseif($number == 0){
$result = 1;
}else{
for($i = $number; $i < 1; $i--){ // We will stop decreasing at 1, because we already included the *1 on the first occurence
$result = $result * $i;
}
}
return $result;
}
This should work, yes, SHOULD, i didn't take time to proofread
function factorial($number){
$result = 1
if($number < 0){ // Only works with positive number;
$result = -1; // Use -1 to display an error message or something
}elseif($number == 0){
$result = 1;
}else{
for($i = $number; $i < 1; $i--){ // We will stop decreasing at 1, because we already included the *1 on the first occurence
$result = $result * $i;
}
}
return $result;
}
This should work, yes, SHOULD, i didn't take time to proofread
This should work, yes, SHOULD, i didn't take time to proofreadOriginally Posted by ebpo
I can't remember C# (or Java for that matters), but let me take a shot at it in PHP, all you got to do is translate
Just to be sure, you want to know how much 5! does for example? This is how I would do it, in PHP again
function factorial($number){
$result = 1
if($number < 0){ // Only works with positive number;
$result = -1; // Use -1 to display an error message or something
}elseif($number == 0){
$result = 1;
}else{
for($i = $number; $i < 1; $i--){ // We will stop decreasing at 1, because we already included the *1 on the first occurence
$result = $result * $i;
}
}
return $result;
}