Skip to content

Instantly share code, notes, and snippets.

@Sergaav
Created March 26, 2015 13:46
Show Gist options
  • Save Sergaav/1da08f2f19862f27e7b9 to your computer and use it in GitHub Desktop.
Save Sergaav/1da08f2f19862f27e7b9 to your computer and use it in GitHub Desktop.
Factorial 4<n<16
package com.gmail.sergaav.dz3_5;
import java.util.Scanner;
public class dz3_5 {
public static void main(String[] args) {
double n;
double fact=1;
int i;
Scanner sc = new Scanner (System.in);
System.out.println("Input a:");
n=sc.nextDouble();
if (n>4 && n<16){
for (i=1;i<=n;i++){
fact=fact*i;
}
System.out.println(fact);
}else System.out.println("A must be 4<n<16");
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment