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

for a challenge involving the mathematical operator of division or integer division

14
votes
2answers
364 views

Impatient divisibility test

Your task is to write a program or function that determines whether a number is divisible by another. The catch is that it should give an answer as soon as possible, even if not all digits of the ...
7
votes
17answers
549 views

Extract and Divide

Challenge For a given positive integer \$n\$: Repeat the following until \$n < 10\$ (until \$n\$ contains one digit). Extract the last digit. If the extracted digit is even (including 0) multiply ...
26
votes
18answers
2k views

Am I a 'Redivosite' Number?

Redivosite is a portmanteau word invented for the sole purpose of this challenge. It's a mix of Reduction, Division and Composite. Definition Given an integer N > 6: If N is prime, N is not a ...
8
votes
2answers
249 views

Integer Division Loops

Challenge Given any positive integer supported by your language: Take the input and divide it into two halves. For all divisions in this program, if the input is odd, round one half up and one half ...
42
votes
16answers
4k views

How small can it get?

Starting with a positive integer N, find the smallest integer N' which can be computed by repeatedly dividing N by one of its digits (in base-10). Each selected digit must be a divisor of N greater ...
10
votes
3answers
231 views

Form a list using prime numbers

You have been given N piles of coins. You have decided to divide each of those B1, B2, ..., BN piles among separate groups of people. The amount of people receiving coins has to be a prime number and ...
27
votes
53answers
2k views

Modulus Summation

I call this sequence "the Jesus sequence", because it is the sum of mod.</pun> For this sequence, you take all the positive integers m less than the input n, and take the sum of n modulo each m. ...
13
votes
25answers
1k views

Calculate the Upper Divmod

Task Given two positive integers (dividend and divisor), calculate the quotient and the remainder. Normally it would be calculated as e = o*q+r where ...
4
votes
3answers
211 views

Solve the equation `a*x == b` with Int32 arithmetics [duplicate]

In this thread we use 32-bit signed integers (assuming the usual two's complement). For simplicity I shall call this type Int32. The range is from -2147483648 ...
19
votes
45answers
2k views

Find the sum of the divisors of N

Write a program that displays on the screen the sum of the divisors of a number (1 ≤ N ≤ 100) entered by the user in the range of 1 to N. This is OEIS A000203. Examples: Input: 7 ...
18
votes
19answers
605 views

Differences of MaxMin Divisor Pairs (DMDP)

Let's talk about divisors... Leaving out perfect squares (for a moment), all positive integers can be expressed as the product of 2 of their divisors. Quick example for ...
19
votes
21answers
3k views

Fold the integer to save space!

The crazy mathematician owns a wide collection of numbers, and therefore the space he has left is quite limited. To save some, he must fold his integers, but unfortunately he is really lazy. Your task,...
31
votes
33answers
3k views

Divisibility Streak

We can define the Divisibility Streak k of a number n by finding the smallest non-negative integer ...
20
votes
32answers
911 views

Product of Divisors

Challenge Given a positive integer, return the product of its divisors, including itself. This is sequence A007955 in the OEIS. Test Cases 1: 1 2: 2 3: 3 4: 8 5: 5 6: 36 7: 7 8: 64 9: 27 10: 100 ...
37
votes
63answers
5k views

Am I divisible by double the sum of my digits?

Given a positive integer as input, your task is to output a truthy value if the number is divisible by the double of the sum of its digits, and a falsy value otherwise (OEIS A134516). In other words: ...
20
votes
35answers
987 views

Proper Divisor mash-up

A proper divisor is a divisor of a number n, which is not n itself. For example, the proper divisors of 12 are 1, 2, 3, 4 and 6. You will be given an integer x, x ≥ 2, x ≤ 1000. Your task is to sum ...
22
votes
12answers
2k views

Divinacci Sequence

Divinacci (OEIS) Perform the Fibonacci sequence but instead of using: f(n) = f(n-1)+f(n-2) Use: ...
15
votes
19answers
1k views

Sum my Fibonaccified divisors!

The famous Fibonacci sequence is F(0) = 0; F(1) = 1; F(N+1) = F(N) + F(N-1) (for this challenge we are beginning with 0). Your challenge: Given n, output the sum ...
14
votes
15answers
728 views

Maximal mutually co-prime factorization

Definitions Two numbers are co-prime if their only positive common divisor is 1. A list of numbers is mutually co-prime if every pair of numbers within that list ...
35
votes
69answers
3k views

Division and remainder

This challenge, while probably trivial in most "standard" languages, is addressed to those languages which are so esoteric, low-level, and/or difficult to use that are very rarely seen on this site. ...
13
votes
12answers
855 views

Sum Chain Sequence

Sequence: We start at 1. We first add the current 1-indexed value to the previous number in the sequence. Then we apply the following mathematical operations in ...
12
votes
20answers
2k views

Division of not so little numbers

Write a program or function that takes in positive integers a, b and c, and prints or ...
22
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 ...
37
votes
98answers
5k views

Divisibility test

Task Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd. You ...
10
votes
8answers
439 views

Draw a phi triangle

Clarification: Basically, you need to make this Euler's totient function has the name phi. Let's try to calculate phi(8) First, list all numbers 8 and under backwards, not including 0 or under <...
25
votes
23answers
4k views

Implement the divisibility-by-7 rule

To check whether a decimal number is divisible by 7: Erase the last digit. Multiply it by 2 and subtract from what is left. If the result is divisible by 7, the original number is divisible by 7. (...
46
votes
62answers
10k views

How even is a number?

The ancient Greeks had these things called singly and doubly even numbers. An example of a singly even number is 14. It can be divided by 2 once, and has at that point become an odd number (7), after ...
31
votes
6answers
1k views

Have you been nice this year?

Introduction Santa has too many names to process, and needs your help! He needs you to write a program or a function, which outputs nice, ...
20
votes
45answers
2k views

Count the divisors of a number

Introduction This is a very simple challenge: simply count the divisors of a number. We've had a similar but more complicated challenge before, but I'm intending this one to be entry-level. The ...
15
votes
4answers
406 views

Calculate A(N) / B(N) with C(N) digits

Consider three number sequences, A, B and C: A: A ...
19
votes
12answers
3k views

Sum of smallest prime factors

SF(n) is a function which computes the smallest prime factor for a given number n. We'll call T(N) the sum of every SF(n) with 2 <= n <= N. T(1) = 0 (the sum is over 0 summands) T(2) = 2 (2 ...
24
votes
6answers
2k views

Closest fraction

Task: Your program is given a proper, positive simple fraction in the format <numerator>/<denominator>. For this input, it must find two fractions. A ...
4
votes
13answers
10k views

Divide Two Numbers Using Long Division

Your challenge is to divide two numbers using long division. The method we used to use in old days of school to divide two numbers. Example here You should NOT use ...
15
votes
9answers
1k views

Implement arbitrary precision division

Implement a function divide(int a, int b, int c) that prints the base 10 value of a/b. without using any floating point math nor ...
8
votes
17answers
7k views

Implement division using only addition

There is a question on the site that asks to implement division without using division. In my case, I am asking you to do the same, but only using addition. What this means is basically: addition is ...
42
votes
55answers
9k views

Divide a number by 3 without using *, /, +, -, % operators

Quoting this question on SO (Spoiler alert!): This question has been asked in an Oracle interview. How would you divide a number by 3 without using *, /, +, -, %, operators? The number ...
10
votes
2answers
658 views

Which Numbers Would Crash this Function?

Which values of x and y will cause a crash with some C compilers? int f(int x, int y) { return (y==0) ? 0 : (x/y); }
16
votes
4answers
2k views

Visualize long division with ASCII art

Write a program that visualizes long division with ASCII art. Input consists of two integers, a numerator and a denominator, using the input format of your choice. Examples: 1234 ÷ 56: <...
15
votes
31answers
2k views

Implement division

Implement a division algorithm in your favourite language which handles integer division. It need only handle positive numbers - but bonus points if it handles negative and mixed-sign division, too. ...