Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [arithmetic]

Challenges related to elementary arithmetic.

13
votes
24answers
835 views

Standardize the Samples (Compute the z-Score)

Given a list of floating point numbers, standardize it. Details A list \$x_1,x_2,\ldots,x_n\$ is standardized if the mean of all values is 0, and the standard deviation is 1. One way to compute this ...
14
votes
19answers
3k views

How much candy can you eat?

Credit to Geobits in TNB for the idea A post without sufficient detail recently posited an interesting game: 2 children sit in front of an array of candy. Each piece of candy is numbered 1 to ...
-3
votes
6answers
123 views

Measuring Mountains [duplicate]

Sum-It is a language I created (quite late) for the Language Design Contest in TNB, for which the theme was "Range". Naturally I interpreted this as "Mountain Range" and created a language about ...
19
votes
38answers
2k views

Given an input, print all exponents where the base and power sum to the input

So this is my first challenge on this site. What this challenge is is that you input a number, and your code spits out numbers which can be calculated as an exponent. The sum of the exponent and base ...
19
votes
13answers
1k views

Dirichlet Convolution

The Dirichlet convolution is a special kind of convolution that appears as a very useful tool in number theory. It operates on the set of arithmetic functions. Challenge Given two arithmetic ...
19
votes
27answers
3k views

Strange Addition

Challenge Calculate the strange sum of two natural numbers (also known as lunar addition): Given A=... a2 a1 a0 and ...
17
votes
19answers
2k views

The Written Digits Sequence

Here's a reasonably trivial sequence which is not in the Online Encyclopedia of Integer Sequences. Start with an empty sequence then define each term as the number of characters required to write out,...
2
votes
13answers
436 views

Validate a barcode [duplicate]

A barcode of EAN-13 symbology consists of 13 digits (0-9). The last digit of this barcode is its check digit. It is calculated by the following means (the barcode ...
10
votes
7answers
631 views

Whose neighbours are hostile?

Introduction For the purposes of this challenge, we will define the neighbours of an element \$E\$ in a square matrix \$A\$ (such that \$E=A_{i,j}\$) as all the entries of \$A\$ that are immediately ...
7
votes
17answers
547 views

Extract and Divide

Challenge For a given positive integer \$n\$: Repeat the following until \$n < 10\$ (until \$n\$ contains one digit). Extract the last digit. If the extracted digit is even (including 0) multiply ...
14
votes
15answers
1k views

Missing numbers in arithmetic sum

Challenge Giving a valid arithmetic sum with some missing numbers, output the full expression. Example: ...
29
votes
18answers
1k views

Custom Number Base Converter

The powers that be want to be able to quickly convert any number they have into their own number base using any format they would like. Input Your program must accept 3 parameters. Number: The ...
18
votes
21answers
2k views

Divide the work

There is a job which can be decomposed into x equally-sized smaller tasks. You have a team of size y <= x, where every member ...
17
votes
34answers
951 views

Calculate power series result [duplicate]

Related: Calculate Power Series Coefficients Given a positive integer \$X\$ and a max exponent (Also a positive integer too) \$N\$ calculate the result of a power series. Example: $$X^0+X^1+X^2+\...
21
votes
2answers
407 views

Subset Sum Orderings

A set of n positive numbers has 2^n subsets. We'll call a set "nice" if none of those subsets have the same sum. ...
21
votes
2answers
566 views

Double a number's continued fraction

Your task is, given x, output 2*x. Easy right!? But there's a catch: x will be given as a (...
16
votes
31answers
1k views

Recover the power from the prime power

It seems that many people would like to have this, so it's now a sequel to this challenge! Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n ...
13
votes
32answers
2k views

Recover the prime from the prime power

Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number. Task: Given a prime power pn > 1, return the prime p. Testcases: <...
4
votes
1answer
313 views

Pair and sort from two integer lists

You are given two arbitrary integer lists, e.g. [-10, 99, -6, 43], [100, 32, 44]. You are to pick one integer from each list and ...
7
votes
4answers
846 views

Insulate the Window Glass and Foil of your house

Introduction: The best options for the glass of your house will: 1. Let through as little heat as possible in both directions (insulation-value Ug). (2. Let ...
9
votes
2answers
433 views

Interpreted arithmetic

A little known fact is that if you turn on enough language extensions (ghc) Haskell becomes a dynamically typed interpreted language! For example the following program implements addition. ...
3
votes
0answers
161 views

Make Three from One [duplicate]

Given a single digit integer and a three digit integer, output a mathematical formula that uses only the single digit and a given list of operators to equal the three digit integer. Input: A one ...
11
votes
1answer
359 views

Not just a four fours puzzle

In this variant of the Four fours puzzle your should use up to x x's (and no other number) and a defined set of operations to ...
-1
votes
1answer
190 views

Find the longest uninterrupted arc in N dimensions

See similar question for 2D case: Find the longest uninterrupted arc The challenge here is to find the longest uninterruped great circle arc around a unit hypersphere in N dimensions, with a random ...
5
votes
3answers
332 views

Find the longest uninterrupted arc

The challenge here is to find the longest uninterruped arc around a unit circle with a random amount of points distributed in random positions around it. Here is a diagram to assist my explanation: ...
20
votes
5answers
1k views

Golfing out the haters

The setup: A social network reports the number of votes a post has in two ways: the number of net upvotes (total upvotes - total downvotes), and the % of votes that were upvotes, rounded to the ...
7
votes
2answers
189 views

Minimal Triangles

Make an upside down triangle of positive integers. Every number in the triangle must be distinct. Each number is the summation of its two parents (similar to how Pascal's triangle is constructed, but ...
5
votes
27answers
1k views

Simple Factorial Challenge [duplicate]

In light of today's date... A factorial of a number n, is the product of all the numbers from 1 to n inclusive. The Challenge Given an integer n where 0 <= n <= 420, find the sum of the ...
15
votes
12answers
749 views

Number of surjections

Task Given 2 positive integers n and k, where n > k, output the number of surjections ...
11
votes
48answers
3k views

Integer logarithms

Given integers N , P > 1 , find the largest integer M such that P ^ M ≤ N. I/O: Input ...
13
votes
13answers
1k views

Arithmetic Cycle

Input: Integer n which is >=0 or >=1 (f(0) is ...
32
votes
24answers
4k views

Sum of five cubes

Given an integer, output five perfect cubes whose sum is that integer. Note that cubes can be positive, negative, or zero. For example, ...
25
votes
30answers
4k views

Zero-sum counting

Write a program or function that given n ≥ 1 returns the number of solutions to ±1 ± 2 ± 3 ± ... ± n = 0. For n = 6 there are no solutions, so the answer is 0. For n = 4 there are ...
14
votes
30answers
3k views

Two steps forward and one step back

Let's say I'm ten steps away from my destination. I walk there following the old saying, "Two steps forward and one step back". I take two steps forward, one back, until I'm standing exactly on my ...
22
votes
24answers
2k views

Ten-pin bowling score - World Bowling edition

World Bowling scoring Many people have gone to their local bowling center to play a few games of bowling, and many people continue to struggle to calculate their scores. World Bowling has introduced ...
25
votes
3answers
1k views

Golf A Free Lunch

Find a maximally profitable sequence of exchanges given an exchange rate table. As an example consider the currencies Ariary (your home currency), Baht, Cedi, and Denar where the rate from one to ...
19
votes
26answers
1k views

Given a number, print out its “collective sum”

Given a number as input, print out its collective sum What is a collective sum? Consider the number 13214, the input Looping through each of the digits starting ...
-5
votes
45answers
843 views

Quartic Summation

Guidelines Task Given two non-negative integers, find the sum of both numbers... to the power of 4. Examples 2, 3 -> 97 (2^4 + 3^4 = 97) ...
26
votes
22answers
2k views

Diluted Integer Sums

A positive integer can be diluted by inserting a 0 between two bits in its binary expansion. This means that an n-bit number has ...
28
votes
8answers
2k views

Find number of ones to get a number using + and *

Introduction Your goal is to find the least number of ones you need to add or multiply together to get the input value, this is A005245. Input One positive integer N. Output The smallest number ...
18
votes
12answers
2k views

Olympic Rings Sequence

Challenge: Given an index integer n, either output the n'th item in this sequence, or output the sequence up to and including ...
6
votes
3answers
283 views

Accumulate some L.s.d

Prior to the decimalisation of Sterling in February 1971, a pound (£ - from Roman libra) comprised 20 shillings (s - solidus), each of 12 pennies (d - denarius). Additionally, until 1960, each penny ...
24
votes
61answers
3k views

The Non-Zero Digital Product Challenge

Originally the Multiplicative digital root Challenge Basically do what the title says Method Given a positive integer 1 <= N <= 100000000 through one of our standard input methods, multiply ...
11
votes
10answers
1k views

Create an N-Dimensional Simplex (Tetrahedron)

The Simplest N-Dimensional shape one can create for any dimension is a Simplex, and this is a set of N+1 points that are all equal distance away from eachother. For 2 dimensions, this is an ...
11
votes
15answers
826 views

Encrypted In Numbers!

The Problem: Two enemy secret agents have devised a wonderful (for you) method of communication! Here’s how the encryption process works: 1) Take the ascii equivalents of each letter. (No spaces, ...
14
votes
6answers
723 views

Match the Striking Clock

Introduction: At home we have a clock that strikes the stated amount at each hour, but also strikes once at every half-hour. So from 0:01 to and including 12:00 it strikes in this order: ...
15
votes
8answers
2k views

Be as evil as possible

Introduction This is a follow-up of this challenge where you're taking the role of that person's evil twin. Being evil you don't want to maximize your share, but rather be as unfair as possible and ...
22
votes
30answers
2k views

What is the missing number (divisibility by 9)

Challenge Given a whole number divisible by 9 and one missing digit, find the missing digit. The missing digit may be represented by any character other than the digits 0-9 as long as it is ...
2
votes
6answers
196 views

52 Week Challenge [duplicate]

The 52 week challenge is a way to save money. For example, Week 1, you save $1.00. Week 2 you save $2.00, and it continues through the year, adding one more dollar to each week’s savings goal. By Week ...
34
votes
21answers
3k views

Easy-to-multiply numbers

Your task is to determine whether two numbers are easy to multiply. This means that their base-10 long multiplication doesn't have any carrying (regrouping) between place values, looking at both the ...