Skip to content

Instantly share code, notes, and snippets.

@resetter
Last active August 29, 2015 14:01
Show Gist options
  • Save resetter/f9414de253860346cf4d to your computer and use it in GitHub Desktop.
Save resetter/f9414de253860346cf4d to your computer and use it in GitHub Desktop.
Permutations
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