Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class Main {
- public static void Run() {
- for (var i = 1; i <= 10; i++) {
- Debug.WriteLine(i + ": " + ErwartungswertMitHelm(i));
- }
- }
- private static double ErwartungswertMitHelm(int wuerfel) {
- return Sum(new int[wuerfel], 0) / Math.Pow(6L, wuerfel);
- }
- private static long Sum(int[] status, int pos) {
- if (pos < status.Length) {
- long sum = 0;
- for (var i = 1; i <= 6; i++) {
- status[pos] = i;
- sum += Sum(status, pos + 1);
- }
- return sum;
- } else {
- return status.GroupBy(s => s).Select(g => g.Key * g.Count()).Max();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement