fork download
  1. import java.util.Random;
  2. import java.util.stream.IntStream;
  3.  
  4. class Ideone {
  5.  
  6. public static void main(String[] args) {
  7. System.out.println("2d6 = " + d(2, 6));
  8. }
  9.  
  10. static int d(int i, int s) {
  11. return IntStream.range(0, i).map(a -> random.nextInt(s) + 1).sum();
  12. }
  13.  
  14. static Random random = new Random();
  15. }
Success #stdin #stdout 0.2s 320832KB
stdin
Standard input is empty
stdout
2d6 = 9