Questions tagged [integer]

For challenges involving the manipulation of integers.

Filter by
Sorted by
Tagged with
48
votes
121answers
7k views

Print all integers

Write a program or function which will provably print all integers exactly once given infinite time and memory. Possible outputs could be: ...
45
votes
20answers
4k views

Greater than less than greater than something fishy

Given a length N string of less-than and greater-than signs (<, >), insert the integers 0 through N at the start and end ...
35
votes
71answers
4k views

As Easy as One-Two-Three

Write a program or function that takes in a positive integer. You can assume the input is valid and may take it as a string. If the number is any of ...
17
votes
15answers
2k views

Write a program that outputs the number of times it has been run [duplicate]

In a programming language of your choice, write a full program that, when run, prints a positive integer N and then modifies its own source file such that the next time it is run it will print N+1. ...
23
votes
33answers
2k views

Where are Champernowne's zeroes?

Consider the infinite string of all nonnegative decimal integers concatenated together in order (akin to Champernowne's constant): ...
23
votes
39answers
4k views

Smallest palindrome divisible by the input

Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by ...
15
votes
20answers
2k views

Smallest positive number whose y-th power is divisible by x

Task Given integers x and y which are both at least 2, find the smallest positive number ...
5
votes
8answers
529 views

Smallest positive integer not yet appeared so that the sum of the first n elements is divisible by n

Task Given positive integer n, output a(n) where a is the sequence defined below: ...
12
votes
5answers
577 views

A047841: Autobiographical numbers

Definition Here is the process to describe a number: For each number from 0 to 9 that is present in the number: Write down the ...
17
votes
9answers
2k views

Integer goes back and forth through time

Input: An integer. Output: First convert the integer to it's equivalent Roman Numeral. Then convert each capital letter of that Roman Numeral to their ASCII/UNICODE decimal value. And output the ...
2
votes
5answers
236 views

“Break” a number [closed]

Origins tl;dw (too lazy, didn't write): thought of it right before I fell asleep Challenge Breaking a number is defined as the following steps: Take a number or a parseable data type as input in ...
2
votes
5answers
3k views

The fastest square root calculator

Write a program which outputs the square root of a given number in the shortest time possible. Rules It may not use any builtins or powering with non-integers. Input format as a function argument ...
21
votes
33answers
2k views

Calculate the sum of ILD

Input: An integer Output: Sum of the input itself + the length of the input + each individual digit of the input. nr + nr-length + {sum of digits} = output ...
8
votes
8answers
565 views

Excludivisible numbers

Given an integer N, output the Nth positive number K with the following property in decimal ...
32
votes
4answers
4k views

The happy Ender problem

The happy ending problem (actually a theorem) states that Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral. The ...
15
votes
33answers
2k views

Separate alphabets and numbers

A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line. Rules:...
9
votes
29answers
3k views

The Nine Pattern

Introduction I stumbled across this (useless) pattern the other day while I was watching TV. I named it "the 9 pattern" because the first number to use it was 9. The gist of it is, you enter a number ...
21
votes
23answers
1k views

Divisor reduction

A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n: ...
7
votes
19answers
1k views

Briefest code to find vowels and print consonants

Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins! Output must look like this: Enter String: Input Vowel Count: a: ...
1
vote
5answers
162 views

Bijective mapping from integers to a variable number of trits

This challenge is a harder version of this one. A variable number of trits is an array of 0 or more trits (a trit is a ternary digit). So [0, 2, 2, 1] is a ...
22
votes
12answers
1k views

Polynomialception

Given two polynomials f,g of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. ...
22
votes
46answers
4k views

Sort an Integer List

The Challenge It's quite simple really, sort a list of numbers. Details You must sort a list of numbers in ascending order, without using any built-in sorting functions/libraries/etc (i.e. ...
15
votes
18answers
1k views

Sorting rectangular matrices

Given a matrix A, we can say that it is "sorted" if each row and column of A is sorted (ascending left-to-right for rows and top-...
38
votes
32answers
6k views

Never tell me the odds

Input A integer n ( ≥ 1) and a digit d (an integer such that 0 ≤ d ≤ 9). In either order; from stdin or parameters or whatever; to a program or function; etc. ...
11
votes
8answers
523 views

Bijective mapping from integers to a variable number of bits

A variable number of bits is an array of 0 or more bits. So [0, 1] is a variable number of bits, but so is []. Write a function ...
25
votes
6answers
3k views

Big big numbers

Whilst trying to golf several of my answers, I've needed to write large integers in as few characters as possible. Now I know the best way to do that: I'll be getting you to be writing this program. ...
9
votes
3answers
539 views

Summation under Zeckendorf Representation

Zeckendorf's theorem shows that every positive integer can be uniquely represented as a sum of non-adjacent Fibonacci numbers. In this challenge, you have to compute the sum of two numbers in ...
15
votes
8answers
809 views

Integral triangles and integral medians

Consider a triangle ABC where each side has integer length (an integral triangle). Define a median of ABC to be a line segment from a vertex to the midpoint of the opposing side. In the figure below, ...
23
votes
3answers
2k views

Stacking Pythagorean Triangles

Background A Pythagorean triangle is a right triangle where each side length is an integer (that is, the side lengths form a Pythagorean triple): Using the sides of this triangle, we can attach two ...
23
votes
2answers
844 views

Help me procrastinate on my computer repairs!

This challenge is brought to you by real (and tragic) inspiration. Recently, the number row on my keyboard has been a bit sporadic. The keys 1-9 work sometimes--but ...
22
votes
29answers
4k views

Find the closest palindromic number

Given a number N, output/return X so that N+X is a palindrome, where |X| has to be as small as possible. Palindrome: A number is a palindrome, if its sequence of digits is the same when reading them ...
30
votes
69answers
8k views

Check whether an integer is a power of 2 without using +,- operations [closed]

Write a program that checks if the integer is a power of 2. Sample input: 8 Sample output: Yes Sample input: ...
2
votes
13answers
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 ...
4
votes
3answers
715 views

Sum of Fibonacci numbers

I found this task here. Given the ith (1<=i<=35) Fibonacci number F(i) calculate the sum of the ith till i+9th number F(i)+F(i+1)+...+F(i+9) and the last digit of the i+246th one F(i+...