When we encounter mathematical theories in everyday contexts, they can often be surprising. In mathematics, the symbol Σ, known as sigma, is used to denote summation. Sigma sums up a series of values, providing a concise way to express total sums within a specified range.
For instance, consider an initial value of 1 and a maximum value of 5. We incrementally add 1 starting from the initial value until we reach the maximum. The summation can be represented and calculated as follows:
More generally, the formula for the sum of the first N integers is given by:
And for the sum of the squares of the first N integers, the formula is:
These formulas are pivotal in calculating expected values, which are crucial in probability analyses, such as deciding whether to participate in a lottery.
Example Scenario: Lottery Decision
Suppose you are considering entering a lottery with an entry fee of 1000 yen. The prizes and their probabilities are as follows:
 1st prize: 10 million yen with a probability of 1/10000
 2nd prize: 500 thousand yen with a probability of 1/50000
 3rd prize: 100 thousand yen with a probability of 1/10000
 4th prize: 10 thousand yen with a probability of 1/1000
 5th prize: 1000 yen with a probability of 1/100
The expected value is calculated by multiplying each prize by its probability and summing these products:


This results in an expected value of 1040 yen. Since the expected value exceeds the entry fee (1040 > 1000), it is statistically advantageous to enter the lottery.
GoLang Script for Sum and Sum of Squares
Below is a GoLang script that calculates the sum and sum of squares for a given maximum value (N):


This script defines a function to compute the sum and sum of squares using the formulas previously mentioned and then executes these calculations for N = 5.
This approach and script offer a practical way to apply mathematical formulas in programming to solve realworld problems efficiently.
Advanced Version
Problem Statement:
Subaru uses a sixfaced pencil, each face labeled from 1 to 6, to randomly decide his answers for a series of questions. Depending on the question type, which can vary from having 3 to 5 possible answers, the roll of the pencil determines his selected answer based on specific rules:
 For a question with 3 possible answers:
 Rolls of 1 or 4 select answer 1.
 Rolls of 2 or 5 select answer 2.
 Rolls of 3 or 6 select answer 3.
 For a question with 4 possible answers:
 Roll of 1 selects answer 1.
 Rolls of 2 or 5 select answer 2.
 Rolls of 3 or 6 select answer 3.
 Roll of 4 selects answer 4.
 For a question with 5 possible answers:
 Rolls of 1 or 4 select answer 1.
 Rolls of 2 or 5 select answer 2.
 Roll of 3 selects answer 3.
 Roll of 4 selects answer 4.
 Roll of 6 selects answer 5.
Subaru needs to answer a total of 50 questions, with each question’s number of possible answers randomly determined to be either 3, 4, or 5.
GoLang Solution:
This solution simulates answering 50 questions using the rules defined above. It randomly decides the number of answers for each question, rolls the dice, and selects the answer based on the roll.

