Previous question:
http://codereview.stackexchange.com/questions/6988/java-application-for-finding-permutations-efficiently> https://codereview.stackexchange.com/questions/6988/java-application-for-finding-permutations-efficiently>
I have changed quite a bit of code, and need some more reviews.
class Permutations {
static long factorial(int num){
long factorial = num;
for (int forBlockvar = num; forBlockvar > 1; forBlockvar--) {
factorial = factorial * forBlockvar;
}
return factorial / num;
}
public static void main(String[] args){
long FactNmR;
int n = 8;
int num = n;
int r = 6;
int nMr = n - r;
long FactN = factorial(num);
if (nMr == 2) {
FactNmR = 2;
}
else if (nMr <= 1){
FactNmR = 1;
}
else if (nMr >= 2) {
num = nMr;
FactNmR = factorial(num);
}
long permutations = FactN;
permutations = permutations / FactNmR;
System.out.println(permutations);
}
}
Previous question:
I have changed quite a bit of code, and need some more reviews.
class Permutations {
static long factorial(int num){
long factorial = num;
for (int forBlockvar = num; forBlockvar > 1; forBlockvar--) {
factorial = factorial * forBlockvar;
}
return factorial / num;
}
public static void main(String[] args){
long FactNmR;
int n = 8;
int num = n;
int r = 6;
int nMr = n - r;
long FactN = factorial(num);
if (nMr == 2) {
FactNmR = 2;
}
else if (nMr <= 1){
FactNmR = 1;
}
else if (nMr >= 2) {
num = nMr;
FactNmR = factorial(num);
}
long permutations = FactN;
permutations = permutations / FactNmR;
System.out.println(permutations);
}
}
Previous question:
I have changed quite a bit of code, and need some more reviews.
class Permutations {
static long factorial(int num){
long factorial = num;
for (int forBlockvar = num; forBlockvar > 1; forBlockvar--) {
factorial = factorial * forBlockvar;
}
return factorial / num;
}
public static void main(String[] args){
long FactNmR;
int n = 8;
int num = n;
int r = 6;
int nMr = n - r;
long FactN = factorial(num);
if (nMr == 2) {
FactNmR = 2;
}
else if (nMr <= 1){
FactNmR = 1;
}
else if (nMr >= 2) {
num = nMr;
FactNmR = factorial(num);
}
long permutations = FactN;
permutations = permutations / FactNmR;
System.out.println(permutations);
}
}
I am that same eighth grader with the Java application for finding permutations efficiently Previous question. I:
I have changed quite a bit of code, and need some more help..reviews.
class Permutations {
static long factorial(int num){
long factorial = num;
for (int forBlockvar = num; forBlockvar > 1; forBlockvar--) {
factorial = factorial * forBlockvar;
}
return factorial / num;
}
public static void main(String[] args){
long FactNmR;
int n = 8;
int num = n;
int r = 6;
int nMr = n - r;
long FactN = factorial(num);
if (nMr == 2) {
FactNmR = 2;
}
else if (nMr <= 1){
FactNmR = 1;
}
else if (nMr >= 2) {
num = nMr;
FactNmR = factorial(num);
}
long permutations = FactN;
permutations = permutations / FactNmR;
System.out.println(permutations);
}
}
Thanks a ton in advanced!
I am that same eighth grader with the Java application for finding permutations efficiently question. I have changed quite a bit of code, and need some more help...
class Permutations {
static long factorial(int num){
long factorial = num;
for (int forBlockvar = num; forBlockvar > 1; forBlockvar--) {
factorial = factorial * forBlockvar;
}
return factorial / num;
}
public static void main(String[] args){
long FactNmR;
int n = 8;
int num = n;
int r = 6;
int nMr = n - r;
long FactN = factorial(num);
if (nMr == 2) {
FactNmR = 2;
}
else if (nMr <= 1){
FactNmR = 1;
}
else if (nMr >= 2) {
num = nMr;
FactNmR = factorial(num);
}
long permutations = FactN;
permutations = permutations / FactNmR;
System.out.println(permutations);
}
}
Thanks a ton in advanced!
Previous question:
I have changed quite a bit of code, and need some more reviews.
class Permutations {
static long factorial(int num){
long factorial = num;
for (int forBlockvar = num; forBlockvar > 1; forBlockvar--) {
factorial = factorial * forBlockvar;
}
return factorial / num;
}
public static void main(String[] args){
long FactNmR;
int n = 8;
int num = n;
int r = 6;
int nMr = n - r;
long FactN = factorial(num);
if (nMr == 2) {
FactNmR = 2;
}
else if (nMr <= 1){
FactNmR = 1;
}
else if (nMr >= 2) {
num = nMr;
FactNmR = factorial(num);
}
long permutations = FactN;
permutations = permutations / FactNmR;
System.out.println(permutations);
}
}