# Tagged Questions

Questions related to elementary arithmetic.

1k views

### Interquartile Mean

Task Given (by any means) a sorted floating point dataset, return (by any means and within 1‰ of the correct value) the interquartile mean. One possible algorithm Discard the lowest and highest ...
1k views

### Substring Sum Set

Introduction Let's observe this array: [3, 2, 4, 1, 1, 5, 1, 2]. Each element displays the length of the substring which must be summed up. Let's take a look at the first element of the above array: ...
2k views

### Divisibility test

Task Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd. You may write a program or a function ...
3k views

### How to weight loss easily?

In this question, we will only focus on losing weight by doing exercise, although there are still many ways to lose weight. Different sports burn different amount of calories. For example, playing ...
2k views

### Generate Pascal's Braid

This is Pascal's Braid: 1 4 15 56 209 780 2911 10864 40545 151316 564719 1 3 11 41 153 571 2131 7953 29681 110771 413403 1542841 1 4 15 56 ...
5k views

### Dijkstra's Challenge

Presented in honor of APL as an interactive tool turning 50 this year Background Ken [Iverson] presented his paper Formalism in Programming Languages in August 1963 at a Working Conference on ...
194 views

### Binary Recurrence Sequences

A binary recurrence sequence is a recursively-defined sequence of the following form: This is a generalization of the Fibonacci (x = 1, y = 2, a = [1, 1], alpha = 1, beta = 1) sequence and the ...
200 views

### The fastest square root calculator [closed]

Write a program which outputs the square root of a given number in the shortest time possible. Rules It may not use any builtins or powering with numbers between 0 and 1. Input format as a ...
657 views

### The Camouflage Color Changing Chameleon Challenge

Chameleon challenges are a bad thing, apparently. Too bad, chameleons are beautiful creatures. Time for a change! As we all know, many chameleons posses a remarkable ability to blend in with their ...
2k views

### Is it a sum-free set?

A set is sum-free if no two (not necessarily distinct) elements when added together are part of the set itself. For example, {1, 5, 7} is sum-free, because all members are odd, and two odd numbers ...
94 views

### Output the happy primes [duplicate]

Input: n Output: A list of length n, with each element being the nth happy prime. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the ...
3k views

### Given two numbers, output their sum

Input: Two decimal integers. These can be given to the code in standard input, as arguments to the program or function, or as a list. Output: Their sum, as a decimal integer. For example, the input 5 ...
1k views

### Calculate the sum of ILD

Input: An integer Output: Sum of the input itself + the length of the input + each individual digit of the item. nr + nr-length + {sum of individual digits} = output For example: Input: 99 ...
744 views

### Choose from an existing set of weights to make a target sum

When doing weightlifting, I want to make a specific weight by attaching several plates to a bar. I have the following plates: 6 plates of 1 kg each 6 plates of 2.5 kg each 6 plates of 5 kg each 6 ...
2k views

### Simplify a square root

Given a positive integer n, simplify the square root √n into the form a√b by extracting all square factors. The outputted a,b should be positive integers with n = a^2 * b with b as small as possible. ...
272 views

### Ways to get to the number

Given the input of the first number and the second number (both positive integers, zero exluded), determine in how many ways could you make the second out of the first, using following actions: +1,+2 ...
2k views

### Count Up, Replace, Repeat!

Definition Define the nth array of the CURR sequence as follows. Begin with the singleton array A = [n]. For each integer k in A, replace the entry k with k natural numbers, counting up from 1 to k....
237 views

### Count, Replace, Add Up! [duplicate]

Definition Define the nth term of the CRAU sequence as follows. Begin with the singleton array A = [n]. Do the following n times: For each integer k in A, replace the entry k with k natural ...
2k views

### Difference of the square of the sum

Find the difference between the square of the sums and sum of the squares. This is the mathematical representation: (∑n)^2-∑n^2 Your program/method should take two inputs, these are your lower ...
2k views

### Leyland Numbers

Given a natural number n, return the n-th Leyland number. Leyland Number Leyland numbers are positive integers k of the form k = x^y + y^x Where x,y are integers strictly greater than 1. They ...
4k views

### The handshake problem

The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur. You code should take an input of any number and ...
482 views

### Excludivisible numbers

Given an integer N, output the Nth positive number K with the following property in decimal base: For each digit I at position P of K, the number formed from K by removing the Pth digit (i.e. I) is ...
359 views

### A Hundred Squares!

Back to basics... As a teacher at the local primary (grade?) school, you need a way to teach your class their times tables. At your disposal, you have hundred squares and a load of red pens. You need ...
7k views

### Weapons of Math Instruction

Last time when I tried to come up with something easy that wasn't a duplicate, it ended up being way too hard.. So hopefully this time it's indeed something newcomers can try as well. Input: An ...
3k views

### Turn an Array into a Math Problem

Given a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where: A plus sign (+) is inserted between pairs of numbers that increase from left to right (a.k.a. ...
1k views

### Sum It Up with a Digital Triangle

Well, sum it down really. Write a program or function that takes in a nonempty list of decimal integers (0-9) and outputs a downward pointing "triangle" of digits with the input list at the top where ...
274 views

### Simplify a Date

This is similar to simplifying fractions, but with Dates! The input of your program must be of the form mm/dd For example 3/4 //March 4 12/15 //December 15 1/1 // January 1 We assume that the ...
3k views

### Has My Pie Been Bisected?

Write a program or function that takes in a nonempty list of positive integers. You may assume it is input in a reasonable convenient format such as "1 2 3 4" or [1, 2, 3, 4]. The numbers in the ...
775 views

### Jam don't add like that

Background Jelly's arithmetic atoms vectorize automatically. In fact, x + y is well-defined whenever x and y are numbers or ragged arrays of numbers. Jelly's source code implements this behavior ...
2k views

### Find the smallest number bigger than the input whose digital sum is the input

"Digital sum" refers to the sum of all the digits in a number. For example, the digital sum of 1324 is 10, because 1+3+2+4 = 10. The challenge is to write a program/function to calculate the ...
3k views

### 24 and 12 Hour Times

Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times: 00:00 12:00am 01:00 1:00am 02:00 2:00am 03:00 3:00am 04:00 4:00am 05:00 5:00am 06:00 6:...
155 views

### Restricted average (arithmetic mean) – i.e. without obvious built-ins [closed]

Introduction The arithmetic mean is defined as being equal to the sum of the numerical values of each and every observation divided by the total number of observations. Symbolically, if we have a ...
178 views

### Find how many pair elements sums up to N [closed]

Based on a recent question in StackOverflow Write a program/function that takes in one ARRAY/list and returns the number of pair-values which sums up to a given TOTAL. Explaining TOTAL=4, ARRAY=[1,...
3k views

### How many steps does it take from n to 1 by subtracting the greatest divisor?

Inspired by this question over at Mathematics. The Problem Let n be a natural number ≥ 2. Take the biggest divisor of n – which is different from n itself – and subtract it from n. Repeat until ...
479 views

### Traveling on a flat Earth

Coordinates in the flat-Earth world consist of latitude (x) and longitude (y), which are integers in the range 0...9999. Much like Gaussian integers, but they are always written using this notation: ...
923 views

### Find the n-th perfect power!

A perfect power is a number of the form a**b, where a>0 and b>1. For example, 125 is a perfect power because it can be expressed as 5**3. Goal Your task is to write a program/function that ...
344 views

### Find the positive divisors!

Definition A number is positive if it is greater than zero. A number (A) is the divisor of another number (B) if A can divide B with no remainder. For example, 2 is a divisor of 6 because 2 can ...
3k views

Background Adler-32 is a 32-bit checksum invented by Mark Adler in 1995 which is part of the widely used zlib library (also developed by Adler). Adler-32 is not as reliable as a 32-bit cyclic ...
289 views

### Find the repetend of the decimal representation!

In this challenge 2 years ago, we found the period of a unit fraction (1/n where n is a natural number). Now, your task is to write a program/function to find the repetend of a unit fraction. The ...
449 views

### Calculate the Kronecker sum of two matrices

In the examples below, A and B will be 2-by-2 matrices, and the matrices are one-indexed. A Kronecker product has the following properties: A⊗B = A(1,1)*B A(1,2)*B A(2,1)*B A(2,2)*B ...
282 views

### One-to-one correspondence between pairs of integers and the positive integers

It is well-known that there are one-to-one correspondences between pairs of integers and the positive integers. Your task is to write code defining such a correspondence (by defining a pair of ...
334 views

### m-nomial coefficient

While binomial coefficient is the coefficient of (1+x)**n, m-nomial coefficient is the coefficient of (1+x+x**2+...+x**(m-1))**n. For example, m(3,5,6) is the coefficient of x**6 in the expansion of (...
608 views

### How many minimum days will he take to complete N units of work?

A person has to complete N units of work; the nature of work is the same. In order to get the hang of the work, he completes only one unit of work in the first day. He wishes to celebrate the ...
2k views

### Sum the odd square numbers less than N

Write a program or function to output the sum of the odd square numbers (OEIS #A016754) less than an input n. The first 44 numbers in the sequence are: 1, 9, 25, 49, 81, 121, 169, 225, 289, 361, 441,...
281 views

### Federal income tax calculator for procrastinators

Today is Tax Day! Oops. Well, today is tax day if you are a resident of Maine or Massachusetts. So you're probably still completing your return and need a calculator for when you get to Line 44. ...
421 views

### Convert to Roman Numeral!

Your task is to convert a given positive integer from Arabic numeral to Roman numeral. Things get difficult when you count to 4000. The romans did this by adding a line above a symbol to multiply ...
886 views

### Generate the minimal remainder sequence

Every number can be represented using an infinitely long remainder sequence. For example, if we take the number 7, and perform 7mod2, then 7mod3, then 7mod4, and so on, we get 1,1,3,2,1,0,7,7,7,7,.......
255 views

### Solve a quadratic equation using Vieta's formulas

Exposition Your mathematics teacher is a big fan of Vieta's formulas, and he believes that you should use them to solve quadratic equations. Given the equation ax^2 + bx + c = 0 the product of its ...