Questions tagged [number]
A competition to solve a particular problem through the usage and manipulation of numbers.
1,222
questions
17
votes
31
answers
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:
...
7
votes
27
answers
5k
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
17
answers
730
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
...
13
votes
47
answers
6k
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 ...
1
vote
13
answers
1k
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
16
answers
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 ...
13
votes
47
answers
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 ...
10
votes
26
answers
2k
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
63
answers
16k
views
Shortest way to reverse a number [closed]
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
7
answers
550
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
2
answers
604
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 ...
5
votes
4
answers
2k
views
Amicable number calculator [closed]
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 ...
17
votes
9
answers
882
views
Last k digits of Powers of 2
For any integer \$r\$, there exists a
power of 2 each of whose last \$r\$ digits
are either 1 or 2.
Given \$r\$, find the smallest \$x\$ such that \$2^x\bmod{10^r}\$ consists of only 1 or 2.
For \$r=...
10
votes
9
answers
5k
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
2
answers
1k
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
8
answers
290
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:
...
14
votes
6
answers
5k
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 ...
11
votes
18
answers
764
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
5
answers
626
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 ...
3
votes
6
answers
432
views
Minimum of last k [closed]
Write a function that takes two arguments: a number k and a list l, and that returns another list ...
6
votes
33
answers
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 ...
145
votes
304
answers
38k
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 ...