Exercise 3: Sum of Even Numbers
Exercise 3: Sum of Even Numbers
Write a Python function to calculate the sum of all even numbers from 1 to a given positive integer (inclusive). The function should take an integer `n` as input and return the sum of all even numbers between 1 and `n`.
- Function: `sum_even_numbers(n)`
– This function takes a positive integer `n` as input and returns the sum of all even numbers from 1 to `n`.
In the main part of the program, ask the user to input a positive integer and call the `sum_even_numbers()` function to compute and display the sum of even numbers.