Skip to content

Commit e6d5e8b

Browse files
authored
Merge pull request #6 from Viniciuswps/master
separando o fatorial recursivo e corrigindo o caso quando n = 0
2 parents 754aabe + 07f98d2 commit e6d5e8b

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Java/Fatorial.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
public class Fatorial {
33

44
public static void main(String [] args){
5-
System.out.println("Fatorial Recursivo de 7 : " + FatorialRecursivo(7) );
65
System.out.println("Fatorial de 7 : " + Fatorial(7) );
76
}
87

9-
public static int FatorialRecursivo(int x){
10-
if(x == 1)
11-
return 1;
12-
else
13-
return x * FatorialRecursivo(x-1);
14-
}
15-
168
public static int Fatorial(int x){
179
int total = 1;
1810
for (int i = 2; i < x+1; i++) {

Java/FatorialRecursiva.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class FatorialRecursiva {
2+
3+
public static void main(String [] args){
4+
System.out.println("Fatorial de 0 : " + Fatorial(0) );
5+
System.out.println("Fatorial de 1 : " + Fatorial(1) );
6+
System.out.println("Fatorial de 3 : " + Fatorial(3) );
7+
System.out.println("Fatorial de 7 : " + Fatorial(7) );
8+
}
9+
10+
public static int Fatorial(int x){
11+
if(x <= 1)
12+
return 1;
13+
else
14+
return x * Fatorial(x-1);
15+
}
16+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Algoritmos em C/C++, Java, Python, Go e Ruby desenvolvidos como estudo de Algori
1919
| 13 | [Exponenciação][13] | C/C++ | Java | [Python](/Python/Exponenciacao.py) | [Go](/GoLang/exponenciacao/exponenciacao.go) | [Ruby](/Ruby/Exponenciacao.rb) |
2020
| 14 | [Exponenciação Recursiva][14] | C/C++ | Java | [Python](/Python/ExponenciacaoRecursiva.py) | Go | [Ruby](/Ruby/ExponenciacaoRecursiva.rb) |
2121
| 15 | [Fatorial][15] | [C/C++](/C/Fatorial.c) | [Java](/Java/Fatorial.java) | [Python](/Python/Fatorial.py) | [Go](/GoLang/fatorial/fatorial.go) | [Ruby](/Ruby/Fatorial.rb) |
22-
| 16 | [Fatorial Recursiva][16] | C/C++ | Java | [Python](/Python/FatorialRecursiva.py) | Go | [Ruby](/Ruby/Fatorial.rb) |
22+
| 16 | [Fatorial Recursiva][16] | C/C++ | [Java](/Java/FatorialRecursiva.java) | [Python](/Python/FatorialRecursiva.py) | Go | [Ruby](/Ruby/Fatorial.rb) |
2323
| 17 | [Fibonacci][17] | C/C++ | [Java](/Java/Fibonacci.java) | [Python](/Python/Fibonacci.py) | [Go](/GoLang/fibonacci/fibonacci.go) | [Ruby](/Ruby/Fibonacci.rb) |
2424
| 18 | [Fila][18] | [C/C++](/C/Fila.c) | [Java](/Java/Fila.java) | [Python](/Python/Fila.py) | Go | [Ruby](/Ruby/Fila.rb) |
2525
| 19 | [Fila Encadeada Dinâmica][19] | [C/C++](/C/FilaEncadeadaDinamica.c) | Java | Python | Go | Ruby |

0 commit comments

Comments
 (0)