Interesting Maths Programming Tasks
ONLY upload your HeAD with Code copied as text and Screenshots of console windows with the code running
1) Arithmetic series (2 chips)
Write a program that allow the user to enter a common difference as an integer. The console should display the first 20 terms in the arithmetic sequence.
For a bonus chip write a function that when given the common difference and ‘n’ returns the nth term.
2) Geometric series (2 chips)
Write a program that allow the user to enter a common ratio as an integer AND the value of the first term. The console should display the 20 terms following the given first term in the Geometric sequence.
For a bonus chip write a function that when given the common Ratio, initial term and ‘n’ returns the nth term.
For another Bonus write as function that returns the sum of a sequence of terms in a geometric sequence
3) Triangular Numbers
Write a program that: outputs the first N terms of the triangle number series AND displays the triangle in Characters e.g.
@
@@
@@@
4) Fibonacci Sequence (5 chips) YOU SHOULD TRY THIS ;)
Write a program that outputs the first 10 terms of the Fibonacci sequence
5) Factorial
Write a program that for a given number will output all the integer factorials up to and including that number. What is the biggest term you can calculate declaring the result as a Long integer?
6) Pascals Triangle (5 chips)
Write a program that displays Pascals triangle on the screen.
7) Prime Numbers (5 Chips)
Write a program that displays all the prime numbers under 1000
8) Greatest common divisor (3 Chips)
Write a program that allows the user to enter 2 integers and returns the Greatest Common Divisor
9) Roman Numeral Decoder / Encoder (5 chips)
Write a program that allows the user to input a Roman numeral and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral.
Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the leftmost digit and skipping any 0s. So 1990 is rendered "MCMXC" (1000 = M, 900 = CM, 90 = XC) and 2008 is rendered "MMVIII" (2000 = MM, 8 = VIII). The Roman numeral for 1666, "MDCLXVI", uses each letter in descending write a second program to create a roman numeral from a decimal
10) Palindrome detector (3 chips)
Write a program that detects if an inputted string is a palindrome. (for an extra chip extend your solution to return any words within a sentence are palindromes
11) Palindromic dates (4 chips)
Not a Christmas dried fruit! List all the dates between 1000AD and today that are palindromic using the dd/mm/yyyy format
12) Pythagorean triple (4 chips + 3 chips for primitives)
defined as three positive integers (a,b,c) where a < b < c, and a2 + b2 = c2. They are called primitive triples if a,b,c are coprime, that is, if their pairwise greatest common divisors gcd(a,b) = gcd(a,c) = gcd(b,c) = 1. Because of their relationship through the Pythagorean theorem, a, b, and c are coprime if a and b are coprime (gcd(a,b) = 1). Each triple forms the length of the sides of a right triangle, whose perimeter is P = a + b + c.
The task is to determine how many Pythagorean triples there are with a perimeter no larger than 100 and the number of these that are primitive.
Write a program that outputs all the Pythagorean triples (3 numbers separated by commas) with a set of starts next to the numbers if they are primitive)