# Questions tagged [division]

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

50 questions
Filter by
Sorted by
Tagged with
2k views

### Divmod continuously until the remainder is 1 or 0, then get the remainder

The task is simple, divide, get the quotient and the remainder, and if the remainder isn't 1 or 0, do the same thing (quotient divmod remainder) until the remainder is 1 or 0, then get the remainder. ...
• 4,225
2k views

### Divisor chain counts (1 3 3 7 ...)

The divisors of a natural number form a poset under the relation of "a divides b?", $a | b$. This challenge is to produce the number, $C$, of non-empty chains of such posets for natural ...
• 109k
1k views

### Find the magic numbers to divide a number without division

An integer $x\in[0,2^{32}-1]$ divided by an integer $d\in{[1,2^{31}]}$ will produce an integral quotient $q$ and a remainder $r$, so that $x=d\times q+r$. Any $q$, in fact, can be ...
• 2,375
2k views

### Is it a Giuga number?

Giuga numbers (A007850) are composite numbers $n$ such that, for each prime factor $p_i$ of $n$, $p_i \mid \left( \frac n {p_i} -1 \right)$. That is, that for each prime factor $p_i$, you ...
• 50.2k
2k views

### Implement Ash's float division

Ash has a bit of an interesting float division algorithm. It's designed to never return NaN, and things like signed zero and infinity need to be handled. How it ...
• 18.9k
631 views

### Zeroes at end of $n!$ in base $m$

Related: Zeroes at the end of a factorial Today, we are going to calculate how many zeroes are there at the end of $n!$ (the factorial of $n$) in base $m$. Or in other words: For given integers \...
• 35k
2k views

### Semidivisibility

NOTE: Some terminology used in this challenge is fake. For two integers n and k both greater than or equal to 2 with ...
904 views

### Prefix divisibility

Inspiration Given a positive integer $1 \le n \le 9$, output all positive $n$-digit integers $i$ for which the following is true: Each digit from $1$ to $n$ appears exactly once in $i$. ...
• 50.2k
192 views

### Is it a Self-divisor? [duplicate]

Task Write a function or program that takes n as a parameter and prints the first n self-divisors. Definition of Self-divisor A ...
• 71
4k views

### How many times, are they multiples?

You are given three parameters: start(int), end(int) and list(of int); Make a function that returns the amount of times all the numbers between start and end are multiples of the elements in the list....
• 441
150 views

### Report divisibility with arithmetic integer operations only [closed]

Given two numbers, the first is greater than the second, check whether the first number is divisible by the second without a remainder. If divisible, answer "yes"(...
• 99
414 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 ...
• 71.6k
637 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 ...
• 967
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 ...
• 195k
324 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 ...
• 773
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 ...
• 195k
264 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 ...
• 335
3k 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. ...
• 3,634
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 ...
• 18.4k
235 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 ...
3k 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 ...
• 315
685 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 ...
4k 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,...
• 42.4k
6k views

### Divisibility Streak [duplicate]

We can define the Divisibility Streak k of a number n by finding the smallest non-negative integer ...
• 7,892
2k 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 ...
• 4,772
6k 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: <...
1k 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 ...
• 42.4k
3k views

### Divinacci Sequence

Divinacci (OEIS) Perform the Fibonacci sequence but instead of using: f(n) = f(n-1)+f(n-2) Use: ...
• 20.8k
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 ...
• 2,106
817 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 ...
• 50k
5k 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. ...
• 12.7k
1k 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 ...
• 130k
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 ...
7k 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 ...
• 39.1k
6k 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 ...
• 50k
517 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 <...
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. (...
• 13.7k
11k 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 ...
2k 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, ...
• 44.5k
6k 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 ...
• 2,272
478 views

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

Consider three number sequences, $A$, $B$ and $C$: $A$: A sequence based on recurrence relations, $f(n) = f(n-1)+f(n-2)$, starting with $f(1) = 3, f(2) = 4$. So, the sequence begins like ...
• 46.4k
4k 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 ...
3k 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 ...
• 2,056
19k views

### Divide Two Numbers Using Long Division [closed]

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 ...
• 2,711
2k 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 ...
• 4,820
9k 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 ...
• 35.1k
11k views

### Divide a number by 3 without using *, /, +, -, % operators [closed]

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 ...
• 3,707
769 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); }
• 17.5k
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: <...
• 10.6k