Skip to main content

Questions tagged [division]

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

Filter by
Sorted by
Tagged with
20 votes
25 answers
2k views

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. ...
Fmbalbuena's user avatar
  • 5,085
15 votes
2 answers
2k views

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 ...
xiver77's user avatar
  • 2,395
26 votes
8 answers
2k views

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 ...
rydwolf's user avatar
  • 19.3k
29 votes
34 answers
2k views

NOTE: Some terminology used in this challenge is fake. For two integers n and k both greater than or equal to 2 with ...
user avatar
4 votes
1 answer
230 views

Task Write a function or program that takes n as a parameter and prints the first n self-divisors. Definition of Self-divisor A ...
John's user avatar
  • 91
-6 votes
5 answers
227 views

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"(...
Mouvre's user avatar
  • 107
7 votes
16 answers
762 views

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 ...
DimChtz's user avatar
  • 967
8 votes
2 answers
359 views

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 ...
DonielF's user avatar
  • 773
10 votes
3 answers
297 views

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 ...
McLinux's user avatar
  • 335
14 votes
24 answers
2k views

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 ...
Rod's user avatar
  • 18.6k
28 votes
70 answers
4k views

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 ...
Kevin Halley's user avatar
21 votes
21 answers
4k views

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,...
Mr. Xcoder's user avatar
  • 42.9k
26 votes
49 answers
2k views

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 12:...
musicman523's user avatar
  • 4,802
23 votes
45 answers
2k views

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 ...
Mr. Xcoder's user avatar
  • 42.9k
15 votes
20 answers
1k views

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 ...
Neil A.'s user avatar
  • 2,126
51 votes
104 answers
6k views

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. ...
Leo's user avatar
  • 12.9k
18 votes
22 answers
2k views

Write a program or function that takes in positive integers a, b and c, and prints or ...
user avatar
43 votes
117 answers
7k views

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 ...
Leaky Nun's user avatar
  • 50.6k
32 votes
31 answers
5k views

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. (...
anatolyg's user avatar
  • 14.1k
31 votes
6 answers
2k views

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, ...
Adnan's user avatar
  • 44.7k
16 votes
4 answers
534 views

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 ...
Stewie Griffin's user avatar
25 votes
6 answers
3k views

Task: Your program is given a proper, positive simple fraction in the format <numerator>/<denominator>. For this input, it must find two fractions. A ...
user2428118's user avatar
  • 2,076
16 votes
9 answers
2k views

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 ...
durron597's user avatar
  • 4,840
49 votes
66 answers
12k views

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 ...
Gaffi's user avatar
  • 3,715
22 votes
5 answers
2k views

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: <...
Joey Adams's user avatar
  • 10.6k