package com.growingwiththeweb.algorithms.interviewquestions.givenrandomfiveimplementrandomseven;

import java.util.Random;

public class Program {
    public static void main(String[] args) {
    }

    public static int random5() {
        return new Random().nextInt(5) + 1;
    }

    public static int random7() {
        // Get 0, 5, 10, 15 or 20 then add 1-5 (4% chance for 1-25)
        int val = (random5() - 1) * 5 + random5();
        // If 1-21, return the result modulo 7 (12% chance for 1-7), otherwise call
        // recursively (16% chance)
        return val > 21 ? random7() : val % 7 + 1;
    }
}

@@ -358,11 +358,11 @@
 add 
-1-5
+0-4
  (4%25
@@ -377,12 +377,12 @@
 for 
-1-25
+0-24
 )%0A  
@@ -419,16 +419,17 @@
 ) * 5 + 
+(
 random5(
@@ -429,16 +429,21 @@
 andom5()
+ - 1)
 ;%0A      
@@ -454,12 +454,12 @@
  If 
-1-21
+0-20
 , re
@@ -483,16 +483,20 @@
 odulo 7 
++ 1 
 (12%25 cha
@@ -522,13 +522,8 @@
 wise
- call
 %0A   
@@ -529,16 +529,21 @@
       //
+ call
  recursi
@@ -580,16 +580,17 @@
 rn val %3E
+=
  21 ? ra

Change random7 result order