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 [number]

This challenge is intended to be solved by using, manipulating, accepting as input, or outputting numeric values.

11
votes
7answers
2k views

Determining the continued fractions of square roots

The continued fraction of a number n is a fraction of the following form: which converges to n. The sequence ...
2
votes
6answers
301 views

All non-empty finite sets of positive integers

The challenge is to create an iterator(/generator) which iterates (in any order so as to reach all of them... ie no set should occur at infinity) over all possible non-empty finite sets(/tuples/lists) ...
6
votes
3answers
1k views

Implementing Binary Arithmetic

Given two binary numbers (strings containing 0s and 1s), perform operations on them, with one problem: You must keep them in binary. That means no going ...
6
votes
12answers
813 views

Range of numbers

Came over a similar problem in a project I'm working on and found it quite hard to solve it without excesive use of if. I'm eager to see if anyone can come up with ...
6
votes
12answers
3k views

add commas to Numbers without String manipulation

This challenge consist in adding commas to numbers every 3 spaces like: 123456789 => 123,456,789 Specifications: The ...
10
votes
16answers
10k views

Random sampling without replacement

Create a function that will output a set of distinct random numbers drawn from a range. The order of the elements in the set is unimportant (they can even be sorted), but it must be possible for the ...
43
votes
37answers
12k views

Outputting ordinal numbers (1st, 2nd, 3rd)

I would like to generate (as a return result of a function, or simply as the output of a program) the ordinal suffix of a positive integer concatenated to the number. Samples: ...
16
votes
29answers
2k views

Finding Not-Quite-Prime Numbers

Your challenge, should you chose to accept it, is to code-golf a function that returns true or false (or some similar meaningful representation of yes and no) if a number meets the following criteria: ...
4
votes
21answers
3k views

determine longest group of consecutive numbers

INPUT: 10 random numbers each number is greater than 0 and less than 100 list of numbers is presorted, lowest to highest the list will not contain any duplicate numbers CHALLENGE: Write a function ...
2
votes
17answers
664 views

The group of sequential positive numbers with the highest sum?

Given the following list of numbers, find the group of sequential positive numbers with the highest sum. Example input: 12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1 ...
14
votes
43answers
4k views

Print the amount of ones in a binary number without using bitwise operators

Description Given a number, print the amount of 1s it has in binary representation. Input A number >= 0 in base 10 that ...
2
votes
13answers
891 views

position of the only 1 in a number in binary format [closed]

Every number of the form 2i (where i is a non-negative integer) has a single 1 in its binary representation. Given such a number, output the 1-based position of the ...
5
votes
16answers
2k views

Hexadecimal To Decimal [closed]

Read input of up to 8 characters presented as hexadecimal number and print this number as decimal number. In case that input can not be presented as hexadecimal input it has to print 0 Rules: It is ...
11
votes
39answers
3k views

Enumerate all palindromic numbers (in decimal) between 0 and n

Given a non-negative integer n, enumerate all palindromic numbers (in decimal) between 0 and n (inclusive range). A palindromic number remains the same when its digits are reversed. The first ...
6
votes
15answers
1k views

Machine Epsilon

Machine epsilon is an important floating point number to know when doing numerical calculations. One way to understand it is when this relation ...
31
votes
64answers
14k views

Shortest way to reverse a number

Write a function (or equivalent subprogram) to accept a single integer valued argument and return a (similarly typed) value found by reversing the order of the base-10 digits of the argument. For ...
7
votes
7answers
525 views

Formatting numbers

Today computers use millions of bytes of memory, and decimal or hexadecimal notations get less and less informative. Most human-readable formatting just display the number with the highest unit ...
10
votes
2answers
533 views

The Prime Grid Game

I had fun solving this, so I offer this golf challenge. The objective of this golf is to find the largest prime number that can be constructed using the given instructions. You should accept 3x3 ...
6
votes
4answers
1k views

Amicable number calculator

Write a program that calculates amicable numbers, starting from [0,0], intil the maximum value for an integer is reached in the language you chose to write it in. Amicable numbers are two different ...
10
votes
9answers
4k views

Arbitrary Base Conversion [closed]

Create a routine that takes an array of blocks in one numeric base system, and convert them to an array of blocks in another numeric base system. Both the from and to systems are arbitrary and should ...
9
votes
2answers
813 views

Floating point addition, without floats!

Your task is to write a program, in any language, that adds two floating point numbers together WITHOUT using any fractional or floating point maths. Integer maths is allowed. Format The format for ...
5
votes
8answers
265 views

Power modulo golf. [closed]

Write a function f(a,b,c) that calculates a^b (mod c) in less than 10 seconds. a, b < 10^100 c < 10000. examples: ...
13
votes
6answers
2k views

Calculate the last digits of Graham's Number

Graham's number ends in a 7. It is a massive number, in theory requiring more information to store than the size of the universe itself. However it is possible to calculate the last few digits of ...
9
votes
15answers
617 views

Output nearby primes

Write a program which takes an input (which may or may not be prime), and lists the immediate prime following and preceding it. Example input: 1259 Example ...
13
votes
5answers
413 views

Perfect powers in more than one way?

Challenge Your task is to write a program or function which, given a positive integer N, finds all positive integers less than or equal to N that can be expressed as a perfect power in more than one ...
6
votes
6answers
403 views

Minimum of last k

Write a function that takes two arguments: a number k and a list l, and that returns another list ...
6
votes
33answers
3k views

Print largest integer you can with the fewest characters [closed]

Find a way to output a large integer with few characters. Solutions will be scored based on the magnitude of the number and shortness of code. EDIT: Let's impose a time limit of a minute on sensible ...
108
votes
218answers
23k views

Fibonacci function or sequence

The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first ...