Last active
August 29, 2015 14:01
-
-
Save resetter/f9414de253860346cf4d to your computer and use it in GitHub Desktop.
Permutations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Permutations | |
{ | |
public static void main (String[] args) | |
{ | |
if (args.length == 0 || args.length == 1) | |
{System.out.println("Not enough arguments supplied"); | |
System.exit(0);} | |
else if (args.length > 2) | |
{System.out.println("Too many arguments"); | |
System.exit(0);} | |
// chars is the number of different characters | |
// length is the length of passphrase | |
int chars = Integer.parseInt(args[0]); | |
int length = Integer.parseInt(args[1]); | |
long result = (long)(Math.pow(chars, length))*(length+1); | |
System.out.println(result + " Bytes"); | |
System.out.println(result / 1024L + " Kilobytes"); | |
System.out.println(result / 1048576L + " Megabytes"); | |
System.out.println(result / 1073741824L + " Gigabytes"); | |
System.out.println(result / 1099511627776L + " Terabytes"); | |
System.out.println(result / 1125899906842624L + " Petabytes"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment