Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

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:

http://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:

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);
 }
}
deleted 59 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I am that same eighth grader with the Java application for finding permutations efficiently Previous question. I:

http://codereview.stackexchange.com/questions/6988/java-application-for-finding-permutations-efficiently>

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:

http://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);
 }
}
edited tags
Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
code format
Source Link
palacsint
  • 30.3k
  • 9
  • 82
  • 157
Loading
Tweeted twitter.com/#!/StackCodeReview/status/149540977995038720
Source Link
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /