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() {
        int val = (random5() - 1) * 5 + random5();
        return val > 21 ? random7() : val % 7 + 1;
    }
}

@@ -323,50 +323,290 @@
     
-int val = (random5() - 1) * 5 + random5();
+// If 1-21, return the result modulo 7 (12%25 chance for 1-7), otherwise call%0A        // recursively (16%25 chance)%0A        int val = (random5() - 1) * 5 + random5();%0A        // If 1-21, return the result modulo 7 (12%25 chance for 1-7), otherwise call%0A        // recursively (16%25 chance)
 %0A   

Add comment to random7 from random5