# Questions tagged [arithmetic]

Challenges related to elementary arithmetic.

541 questions
Filter by
Sorted by
Tagged with
3k views

### American odds to probabilities

American odds (aka moneyline odds) are numbers like $+150$ or $-400$ used to express how much a winning bet would pay out. Convert odds to a fair win probability like this: Positive odds $+n$ ...
719 views

### Otteretto Classic game scoring method

Brief description of the game In the game Otteretto Classic (which you can test directly in your browser; try it!) the player has to form palindromic sequences using adjacent cells on a square grid. ...
3k views

### Compare Two Fractions With ASCII Art

Challenge Write a program or function that takes in 4 non-negative integers, A, B, C, and D, that represent two fractions, A/B and C/D, where B and D are non-zero and A <= B and C <= D. Output ...
4k views

### Given 4 fence lengths, what's the largest rectangular yard you can make?

Here's a very simple little problem that I don't believe has been asked before. Challenge Write a program or a function that takes in four positive integers that represents the lengths of movable but ...
2k views

### Add two real numbers ... probably

The problem statement here is pretty simple, take two real numbers on the range [0,1) as input and output their sum, with probability 1. The catch here is that there are a lot of real numbers. There ...
3k views

### Summing the Digits of a Number

Challenge Given a non-negative integer, find the sum of its digits. Rules Your program must take a non-negative integer as input. Your program should output the sum of the digits of the input ...
865 views

### Parse basic arithmetic into an AST

Introduction An abstract syntax tree (AST) is a tree of tokens that shows their connection to each other and syntactical meaning. They are commonly used in compilers and static analysis tools, as ...
1k views

### Division between two strings

Inverse function of this challenge To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick ...
503 views

### Iterate through addition of number sequence until a single digit [closed]

Challenge: With any given number that has multiple digits, every digit in the number needs to repeatedly be summed together until the sum is a single digit number. To make things interesting, if there'...
1k views

### Carry-less sum given a base b

Given a list of positive integers $\mathcal I=I_1,I_2,I_3,...,I_n$ and a base $b>1$ return their "carry-less sum", i.e. represent $\mathcal I$ in base $b$ and sum digit-by-digit ...
1k views

### Cartesian - polar conversion couple

We don't have a challenge for conversion between Cartesian and polar coordinates, so ... The challenge Write two programs (or functions) in the same language: one that converts from polar to ...
1k views

### Cryptic Multiplications

Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592. If now each digits is ...
346 views

### Decompose number N into the sum of three triangular numbers [closed]

It is known that any natural number can be decomposed into the sum of three triangular numbers (assuming 0 is triangular), according to Fermat's Polygonal Number Theorem. Your task is to come up with ...
1k views

### Implement Binary Exponentiation

Background In programming, there is a recursive algorithm called binary exponentiation, which allows for large integer powers to be calculated in a faster way. Given a non-zero base $x$ and a non-...
1k views

### Extract the contained powers of two!

Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases ...
2k views

### Palindromic Powers

Powers We define an important power as a number that can be represented as $x^y$ where $x ≥ 2$ and $y ≥ 2$. Palindrome We define an ...
2k views

### Random Point from a 2D Donut Distribution

A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius <...
319 views

### No parentheses shall be omitted

This expression actually has an omitted pair of parentheses. 1 + 2 * 3 To make things clear, it should be, 1 + (2 * 3) Even ...
3k views

### Make S + S + ... + S as Large as Possible!

Let $S \subset \mathbb N_{\geq0}$ be a subset of the nonnegative integers, and let $$S^{(k)} = \underbrace{S + S + \dots + S}_{k\ \textrm{times}} = \{ a_1 + a_2 + \dots + a_k : a_i \in S\}.$$ For ...
603 views

### Khinchin's constant bad estimate [closed]

Inspired by How to write down numbers having an infinity of decimals? Link 🇫🇷 Background From Wikipedia: for almost all real numbers $x$, coefficients $a_i$ ...
2k views

### Hunt for discount

Story My local pizza delivery introduced new discount. You get 50% discount from every second item on your order. But being greedy capitalists, they forgot to mention that they will rearrange items ...
2k views

709 views

### Next to the middle

Given an array of integers, find "the next to the middle". The next to the middle is the smallest integer greater than the smallest among mean, median and mode of the given numbers, that is ...
165 views

### 8 out of 10 programmers like countdown [duplicate]

Edit (Jan 24/2021): The original specification for the challenge had a few problems. Underneath the original text, I have added alternate conditions that were suggested by @caird-coinheringaahing (...
208 views

### increment a binary number without arithmetic manipulations [closed]

Input: binary string Output: binary string that represents the binary input + 1 Example: Given 10111 as an input, output 11000 ...