Questions tagged [arithmetic]

Challenges related to elementary arithmetic.

Filter by
Sorted by
Tagged with
-2 votes
1 answer
232 views

Square root of a base 10 positive integer, digit by digit [closed]

It is possible (Wikipedia reference) to compute the square root of any number in a digit by digit fashion using a simple (I had learned it in primary school) algorithm. Challenge: read a positive ...
gboffi's user avatar
  • 113
14 votes
9 answers
2k views

We're much closer than you think

Martin Ender's 2D programming language Alice has two different modes depending on what orientation the IP has: orthogonal (Cardinal mode) or diagonal (Ordinal mode). Commands in Alice change their ...
caird coinheringaahin g's user avatar
34 votes
7 answers
4k views

Shortest "arithmetic" formula to output 1000 primes

Write a formula using only the digits 0-9, +, *, -, <...
prime_directive's user avatar
15 votes
16 answers
1k views

Concatenations of powers and their squares

At time of writing, my reputation is \$16,256\$. As I noted in chat, Oh cool my rep is the concatenation of two powers of 2: 16,256 Or even the concatenation of a power of 2 and its square, which is ...
caird coinheringaahin g's user avatar
55 votes
148 answers
8k views

The vanilla factorial challenge

Task Given a non-negative integer \$n\$, evaluate the factorial \$n!\$. The factorial is defined as follows: $$ n!=\begin{cases}1 & n=0\\n\times(n-1)!&n>0\end{cases} $$ Rules All default I/...
Bubbler's user avatar
  • 75.1k
3 votes
19 answers
792 views

Find your dog's age

Task Take the (integer) number of human years that the dog has lived, \$n\$, as input and return its age in dog years, \$d\$, to two decimal places. The number of human years, \$n\$, will be between \$...
Razetime's user avatar
  • 27k
19 votes
12 answers
2k views

Slowing Down Sped Up Videos

Summary Videos which are sped up every time a particular word is said exist for everything from the Bee Movie to the classic Rick Roll. The goal for this challenge is to figure out how much you'd have ...
stevenjackson121's user avatar
34 votes
70 answers
4k views

Sum the array times n, except the last

I've been posting relatively hard challenges recently, so here goes an easy one. Task Given an array \$A\$ and a number \$n\$, calculate the sum of all numbers of \$A\$ multiplied by \$n\$, except the ...
Bubbler's user avatar
  • 75.1k
42 votes
5 answers
4k views

Compute xkcd's Wrong Times Table

The 2020-05-29 xkcd comic showed us the numbers that Randall Munroe feels would be most likely to result from multiplication, other than the correct answers. The table does seem to have some sort of ...
Aaron Rotenberg's user avatar
23 votes
70 answers
3k views

Check if an array (or equivalent) has the same number of odd and even numbers - Code Golf Edition!

Inspired by this code review question, I am curious to see what happens if we turn that into a code-golf challenge! The description is easy, the input is an array or any similar data structure with ...
bracco23's user avatar
  • 431
9 votes
8 answers
676 views

Perfect scores in Martian rules football

Story Martians have been observing Aussie rules football matches from space with great curiosity. Having totally fallen in love with the game, they have been inspired to start their very own football ...
Dingus's user avatar
  • 11.1k
-3 votes
1 answer
113 views

How to find the original value based on modulus/reminder and some other information [closed]

This might be a very basic question in terms of math, x % constant = x_modulus (x + some_number) % constant = y_modulus Given the value of ...
Tejas Sarade's user avatar
9 votes
1 answer
394 views

Multiplication algorithm on a 4004

So I was playing around with this emulator of the Intel 4004 and decided I wanted to set a challenge for myself. The first use for the 4004 was in a calculator, so I decided that I would try to code ...
Nip Dip's user avatar
  • 415
24 votes
11 answers
2k views

Generate A065825

(This is A065825.) The sequence defaults apply, so you can pick another format other than this one. Given an input integer n, find the smallest number ...
user avatar
17 votes
9 answers
2k views

Euler's Geometry Puzzle

Today (or tomorrow, depending on your timezone, by the time of posting) is the birthday of the great mathematician and physicist Leonhard Euler. To celebrate his birthday, this challenge is about one ...
newbie's user avatar
  • 1,150
13 votes
6 answers
854 views

Boil eggs using hourglasses

These are the classical puzzles: You need to boil eggs for exactly 9 minutes, or else the visiting Duchess will complain, and you will lose your job as head chef. But you have only 2 Hourglasses, one ...
anatolyg's user avatar
  • 13.4k
19 votes
16 answers
1k views

(RGS 4/5) Inverting matrices modulo m

Task Given an integer matrix M and a modulus m, find an inverse of M modulo ...
RGS's user avatar
  • 14.1k
38 votes
53 answers
3k views

(RGS 1/5) Binary multiples [duplicate]

A binary multiple of a positive integer k is a positive integer n such that n is written ...
RGS's user avatar
  • 14.1k
39 votes
13 answers
3k views

Phony fractions

Context If a0 and b0 are two decimal numbers, with a and ...
RGS's user avatar
  • 14.1k
2 votes
5 answers
192 views

Shift the digits [closed]

Here, x (supplied as input) and n (the result of your computation) are both positive integers. n * x = n shifted. Find n. Here's an example of shifting: ...
user avatar
12 votes
9 answers
1k views

Integer Logarithm

Objective Take \$a \in ℤ_{>1}\$ and \$b \in ℤ_+\$ as inputs. Write a function \$f\$ such that: $$ f(a,b) = \left\{ \begin{array}{ll} \log_ab & \quad \text{if} \space \log_ab \in ℚ \\...
Dannyu NDos's user avatar
  • 5,639
21 votes
25 answers
2k views

Power-Ending Patterns

When you look at the last decimal digit of each power of a non-negative integer a repeating pattern forms. For example, 3: ...
Calvin's Hobbies's user avatar
47 votes
58 answers
9k views

Shift right by half a bit

The challenge is to implement a program or function (subsequently referred to as "program") that takes a nonnegative integer \$n\$ as input and returns \$n\over\sqrt{2}\$ (the input divided by the ...
Deadcode's user avatar
  • 11.6k
5 votes
16 answers
3k views

Move my liquid to make me equal

You are given 4 positive integers: volume of the first container (v1), volume of the second container (v2), volume of the liquid ...
user avatar
9 votes
5 answers
382 views

Play flip--flop

Flip flop is a memory / arithmetic game that I played in high school. Some number of players stand in a circle. The players take turns. On the nth turn, the current ...
Hood's user avatar
  • 2,095
28 votes
13 answers
3k views

Who's next to me in the queue?

Problem 4 in the 2019 BMO, Round 1 describes the following setup: There are \$2019\$ penguins waddling towards their favourite restaurant. As the penguins arrive, they are handed tickets numbered ...
FlipTack's user avatar
  • 14.6k
21 votes
93 answers
5k views

Average Two Letters

Introduction Every letter in the English alphabet can be represented as an ASCII code. For example, a is 97, and ...
sugarfi's user avatar
  • 2,193
2 votes
0 answers
60 views

Spreadsheet Columns [duplicate]

Spreadsheet Columns In most spreadsheet programs, columns go A, B, C, ... ...
gadzooks02's user avatar
20 votes
54 answers
3k views

Find the percentage

We haven't had any nice, easy challenges in a while, so here we go. Given a list of integers each greater than \$0\$ and an index as input, output the percentage of the item at the given index of the ...
caird coinheringaahin g's user avatar
44 votes
26 answers
10k views

Random point on a sphere

The Challenge Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction. This is equivalent to a random point on ...
Jitse's user avatar
  • 6,896
21 votes
12 answers
3k views

Calculate Landau's function

Landau's function \$g(n)\$ (OEIS A000793) gives the maximum order of an element of the symmetric group \$S_n\$. Here, the order of a permutation \$\pi\$ is the smallest positive integer \$k\$ such ...
Daniel Schepler's user avatar
21 votes
4 answers
512 views

Compute height of Bowl Pile

Bowl Pile Height The goal of this puzzle is to compute the height of a stack of bowls. A bowl is defined to be a radially symmetric device without thickness. Its silhouette shape is an even ...
pasbi's user avatar
  • 451
21 votes
26 answers
2k views

Start from ones

Given a strictly positive integer n, follow these steps: Create an array A with n 1s. If A only has one element, terminate. Otherwise, starting from the first element, replace each pair of A with its ...
Erik the Outgolfer's user avatar
22 votes
14 answers
6k views

Look mom! I made my own (Base 10) numeral system! [closed]

We've all done it, well, maybe not, but making your own alien language and numbering system is a staple of especially fantasy writing, but is mostly just a fun activity. The task is simple, take two ...
Bill W's user avatar
  • 337
12 votes
5 answers
979 views

Does this addition pyramid puzzle have a unique solution?

Given an addition pyramid \$P\$, determine whether it can be solved. An addition pyramid consists of layers, each having one number less than the one below it. Layer \$i\$ is symbolized as \$P_i\$. \$...
Erik the Outgolfer's user avatar
74 votes
5 answers
9k views

Machine Learning Golf: Multiplication

I'd like to propose a different kind of golfing challenge to this community: (Artificial) Neural Networks are very popular machine learning models that can be designed and trained to approximate any ...
Stefan Mesken's user avatar
22 votes
6 answers
1k views

Subtract the Folded Matrix

Challenge: Given an NxN matrix where \$N\geq2\$ and one of eight distinct 'folding options', output a 2D array/list with the subtracted values. The eight folding options are: left-to-right; right-to-...
Kevin Cruijssen's user avatar
6 votes
12 answers
338 views

Probabilistic approach puzzle

A few hours earlier, I got this puzzle: Suppose, you toss a coin n times, then what is the probability of getting m number of heads? ( where m belongs to the set of all prime numbers) For instance,...
vrintle's user avatar
  • 2,980
53 votes
67 answers
7k views

Multiplicative persistence

Multiplicative Persistence Multiply all the digits in a number Repeat until you have a single digit left As explained by Numberphile: Numberphile "What's special about 277777788888899?" ...
SQB's user avatar
  • 781
36 votes
5 answers
8k views

Historical difference between `/` and `÷` in mathematical expressions

Introduction: Inspired by a discussion that is already going on for many years regarding the expression \$6÷2(1+2)\$. With the expression \$6÷2(1+2)\$, mathematicians will quickly see that ...
Kevin Cruijssen's user avatar
19 votes
15 answers
1k views

Spot all (anti)diagonals with duplicated values

Challenge: Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers. So if we have a matrix like this: ...
Kevin Cruijssen's user avatar
1 vote
2 answers
246 views

Work out \$x^y\$ using only addition and subtraction [duplicate]

The challenge is to implement a function or program that takes two numbers, \$x\$ and \$y\$ and return the result of \$x^y\$. The program cannot use any other mathematical operation other than \$+\$ ...
Olly Britton's user avatar
2 votes
3 answers
214 views

All the digisibles [duplicate]

A natural number (written in the decimal base) is qualified as digisible if and only if it fulfills the following 3 conditions: none of its digits is zero, all the digits that compose it are ...
mdahmoune's user avatar
  • 2,862
14 votes
26 answers
1k 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 ...
flawr's user avatar
  • 43.8k
13 votes
19 answers
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 ...
Mayube's user avatar
  • 11.6k
-4 votes
6 answers
171 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 ...
Mayube's user avatar
  • 11.6k
23 votes
40 answers
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. The challenge is to take in an input integer \$n\$, which will be positive, and print, in ascending order (\$1\$ to \$n\$, including n), the output of \$i^{...
Gymhgy's user avatar
  • 7,998
22 votes
14 answers
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 ...
flawr's user avatar
  • 43.8k
26 votes
34 answers
4k views

Strange Addition

Challenge Calculate the strange sum of two natural numbers (also known as lunar addition): Given \$A=...a_2 a_1 a_0\$ and \$B=... b_2 b_1 b_0\$ two natural numbers written in the decimal base, the ...
mdahmoune's user avatar
  • 2,862
19 votes
20 answers
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,...
Jonathan Allan's user avatar

1
2
3 4 5
11