import java.util.*;

public class Main {
    public static void main(String[] args) {
        Long lowLimit = 3L;
        Long highLimit = 12L;

        // Create a list to store the result i.e total number of ways to choose sum so that max possible participants win the lottery, number of participants who will win the lottery
        List<Long> finalResult = new ArrayList<>();

        // Create a HashMap to store the number of times each sum appears
        Map<Long,Long> map = new HashMap<>();

        // Loop through the lowLimit and highLimit to get the List of Sum of digits of each number
        for (Long i = lowLimit; i <= highLimit; i++) {
            Long j = i;
            Long sum = 0L;
            while (j != 0) {
               sum = sum + j % 10;
               j /= 10L;
            }
            if(map.containsKey(sum)) {
                map.put(sum, map.get(sum) + 1L);
            }else {
                map.put(sum, 1L);
            }
        }
        System.out.println("Map: " + map);

        // The max number of winners will be the maximum value in the map
        Long winners = Collections.max(map.values());
        System.out.println("Number of winners: " + winners);

        // To get the number of ways to win, count the number of keys that have the maximum values in the map
        Long ways = 0L;
        for (Long sum : map.values()) {
            if(Objects.equals(sum, winners)){
                ways++;
            }
        }
        System.out.println("Number of ways to win: " + ways);

        finalResult.add(ways);
        finalResult.add(winners);

        System.out.println("Final result " + finalResult);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: