### Category -> Math Solutions

### Write a method that accepts an int parameter and recursively calculates the sum of the numbers from 1 to the parameter.

Posted January 7, 2020

Tags:

The Problem: The sum of the numbers from 1 to n can be defined recursively as follows: The sum from 1 to 1 is 1. The sum from 1 to n is n more than the sum from 1 to n-1. Write a int-method named sum that accepts an int parameter, n, and recursively calculates and .... Read More

### Write a method that takes a single int parameter and returns that element of the Fibonacci series.

Posted December 3, 2019

Tags: , Recursion

The following Java coding solution is the first in a series of solutions for common recursion programming problems. It is perhaps not the best solution, and certainly not the only solution. If youâ€™ve got a better idea, please share. Problem: The Fibonacci series: 0, 1, 1, 2, 3, 5, 8, 13, 21, has as its first 2 values, 0 and 1; each successive v .... Read More

### Method that recursively calculates the factorial value

Posted December 2, 2019

Tags: , Recursion

The following Java coding solution is the first in a series of solutions for common recursion programming problems. It is perhaps not the best solution, and certainly not the only solution. If you've got a better idea, please share. Problem: Write a method called fact that recursively calculates the factorial value of its single int parameter. The value returned by fact is a long. .... Read More

### Using Python: Counting Prime Numbers

Posted February 19, 2018

Tags:

When children first hear of 'prime' numbers in elementary school, they are likely seen as just another abstract concept in mathematics. However, like most of what we learned in elementary school, prime numbers have vast practical use in our world today, including in the world of computer programming and communications. A prime number is a whole number greater than 1 whose only factors are 1 and itself. A factor is a whole n .... Read More

### Using Python: Finding Divisors

Posted February 9, 2018

Tags:

Today's post is admittedly a more basic variety - using Python to find the divisors of numbers. Python has proven itself very adept in the rapidly growing world of data science. Students are finding their way into introductory Python programming more and more. The following program may help point one of them in the right direction. Of course, it remains for them to use that direction to develop their own original work. Enjoy the program and, of course, feel free to email me at martin@mdbytes.c .... Read More