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.

10
votes
7answers
610 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
539 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
943 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
403 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
554 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
311 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
841 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
422 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
159 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
357 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
186 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
326 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
188 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
733 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
825 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. Input One positive integer N. Output The smallest number of ones that must ...
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
997 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
823 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
715 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
190 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 ...
33
votes
33answers
5k views

Be as fair as possible

Introduction In this challenge you should split an integer into two pieces. Since nobody likes getting the smaller piece of cake, your goal is to be as fair as possible. For example if you wanted to ...
9
votes
1answer
435 views

The working time calculator

This is based on how my company deals with the monitoring of the working times for every employee. Each one of us has a card that can be passed in front of a sensor, so that a clock registers the ...
25
votes
3answers
2k views

A regex to match three consecutive integers iff the third integer is the sum of the first two

Write a regular expression which matches a given string consisting of three non-negative, space-separated integers if and only if the last integer is the sum of the previous two. Answers may be for ...
13
votes
25answers
1k views

Calculate the Upper Divmod

Task Given two positive integers (dividend and divisor), calculate the quotient and the remainder. Normally it would be calculated as e = o*q+r where ...
9
votes
9answers
465 views

Advent Challenge 3: Time to remanufacture the presents!

<< Prev Next >> Unfortunately, Santa was not able to catch the elves in time! He has to go back to manufacturing presents now. Since the elves are definitely not Santa's slaves, he has to ...
14
votes
14answers
1k views

Mod-balanced lists

Introduction Suppose I have a list of integers, say L = [-1,2,2,1,2,7,1,4]. I like having balance in my life, so I'm happy to see it has as many odd elements as even elements. What's more, it also ...
14
votes
31answers
1k views

2 factors factorization

Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve ...
6
votes
10answers
572 views

Compute the result of an equation, but with selectable operator precedence

Forget BIDMAS! Write a program that takes an equation and an operator precedence order, and prints the result. Example input format: 1.2+3.4*5.6/7.8-9.0 */+- ...