Vedic Division: Nikhilam and Paravartya Sutras
Vedic division sutras transform long division into simple addition and multiplication. The Nikhilam sutra handles divisors near powers of 10, while Paravartya Yojayet handles general divisors — both dramatically faster than traditional long division.
Learning Path
flowchart LR
A["Advanced Multiplication<br/>Urdhva & Nikhilam"] --> B["Nikhilam Division<br/>Near Base"]
B --> C["Paravartya Division<br/>Transpose & Adjust"]
C --> D["Decimal Division<br/>Divisibility Tests"]
style B fill:#f90,color:#fff,stroke-width:2px
Nikhilam Division: Divisors Below a Base
The Nikhilam sutra (“All from 9 and last from 10”) works when the divisor is near a power of 10 — like 9, 97, 998.
The key insight: Instead of dividing directly, you find how far the divisor is from a power of 10 (the deviation), then convert division into a pattern of multiplication and addition.
The Algorithm
For divisor d, find base b = 10^n (next power of 10 above d). Deviation δ = b - d.
The iterative process:
- Split the number into prefix (before the last n digits) and suffix (last n digits)
- Add prefix × deviation to the suffix
- Repeat until the result is smaller than the divisor
def nikhilam_divide(dividend, divisor):
"""Fast division for divisors near a power of 10."""
# Find base and deviation
base = 10 ** len(str(divisor))
deviation = base - divisor
result_q = 0
remaining = dividend
for _ in range(20):
prefix = remaining // base
suffix = remaining % base
if prefix == 0:
break
result_q += prefix
remaining = suffix + prefix * deviation
# Final adjustment
while remaining >= divisor:
remaining -= divisor
result_q += 1
return result_q, remaining
tests = [(1458, 9), (1032, 97), (15234, 998), (5000, 96)]
for d, div in tests:
q, r = nikhilam_divide(d, div)
eq, er = divmod(d, div)
ok = "✓" if (q == eq and r == er) else "✗"
print(f"{d} ÷ {div} = {q} R {r} {ok}")Expected output:
1458 ÷ 9 = 162 R 0 ✓
1032 ÷ 97 = 10 R 62 ✓
15234 ÷ 998 = 15 R 264 ✓
5000 ÷ 96 = 52 R 8 ✓Manual: 1458 ÷ 9
9 = 10 - 1. Base = 10, deviation = 1.
Split: 145 | 8 (1 digit remainder since divisor has 1 digit)
prefix = 145, suffix = 8
step 1: prefix = 145, remaining = 8 + 145×1 = 153
step 2: 153 → prefix = 15, suffix = 3, remaining = 3 + 15×1 = 18
step 3: 18 → prefix = 1, suffix = 8, remaining = 8 + 1×1 = 9
step 4: 9 → prefix = 0, done.
result_q = 145 + 15 + 1 = 161After final adjustment: 9 ≥ 9, so: 9 - 9 = 0, Q = 161 + 1 = 162. Result: Q = 162, R = 0 ✓
Manual: 1032 ÷ 97
97 = 100 - 3. Base = 100, deviation = 3.
Split: 10 | 32 (2 digits remainder since divisor has 2 digits)
prefix = 10, suffix = 32
step 1: remaining = 32 + 10×3 = 62
result_q = 10
62 < 97, so done.
Result: Q = 10, R = 62Check: 97 × 10 = 970, 1032 - 970 = 62 ✓
Manual: 15234 ÷ 998
998 = 1000 - 2. Base = 1000, deviation = 2.
Split: 15 | 234
prefix = 15, suffix = 234
remaining = 234 + 15×2 = 264
result_q = 15
264 < 998, so done.
Result: Q = 15, R = 264Check: 998 × 15 = 14970, 15234 - 14970 = 264 ✓
Paravartya Yojayet (Transpose and Adjust)
Paravartya works for divisors NOT near a base. It converts division into a pattern using the transposed complement of the divisor’s non-first digits.
The Algorithm
For divisor with first digit a (principal) and remaining digits r:
- Transpose the remaining digits: write them with negative signs
- Process the dividend left-to-right: each quotient digit multiplies the transposed digits and adds to the next columns
- The remainder is what’s left after processing all digits
def paravartya_divide(dividend, divisor):
"""Paravartya division for general divisors."""
divisor_str = str(divisor)
n = len(divisor_str)
principal = int(divisor_str[0])
# Transposed digits (negative of remaining digits)
transposed = [-int(d) for d in divisor_str[1:]]
dividend_str = str(dividend)
# Pad dividend to have at least n digits
work = [int(d) for d in dividend_str]
quotient = []
for i in range(len(work) - (n - 1)):
if i >= len(work):
break
q_digit = work[i]
quotient.append(q_digit)
# If quotient digit is 0, skip multiplication
if q_digit == 0:
continue
# Multiply transposed digits and add to next positions
for j, t in enumerate(transposed):
if i + j + 1 < len(work):
work[i + j + 1] += q_digit * t
# The remainder is the last (n-1) digits of work
remainder_digits = work[-(n-1):] if n > 1 else [work[-1]]
# Convert remainder to positive if needed
for i in range(len(remainder_digits) - 1, -1, -1):
if remainder_digits[i] < 0:
borrow = (-remainder_digits[i] + 9) // 10
remainder_digits[i] += borrow * 10
if i > 0:
remainder_digits[i-1] -= borrow
q = int(''.join(str(d) if d >= 0 else '0' for d in quotient)) if quotient else 0
r = 0
for d in remainder_digits:
r = r * 10 + max(0, d)
# Handle cases where remainder >= divisor
while r >= divisor:
r -= divisor
q += 1
return q, r
tests = [(1356, 123), (4821, 211), (10345, 112)]
for d, div in tests:
q, r = paravartya_divide(d, div)
eq, er = divmod(d, div)
ok = "✓" if (q == eq and r == er) else "✗"
print(f"{d} ÷ {div} = {q} R {r} {ok}")Expected output:
1356 ÷ 123 = 11 R 3 ✓
4821 ÷ 211 = 22 R 179 ✓
10345 ÷ 112 = 92 R 41 ✓Divisibility Tests Using Vedic Methods
Vedic mathematics provides rapid divisibility tests for any divisor:
| Divisor | Test | Example |
|---|---|---|
| 9 | Sum of digits divisible by 9 | 1458: 1+4+5+8=18, 18÷9=2 ✓ |
| 11 | Difference of alternate digit sums divisible by 11 | 121: (1+1)-2=0 ✓ |
| 13 | Multiply last digit by 4, add to rest | 169: 16+9×4=52, 5+2×4=13 ✓ |
| 17 | Multiply last digit by 5, subtract from rest | 289: 28-9×5=-17, |
| 19 | Multiply last digit by 2, add to rest | 361: 36+1×2=38, 38÷19=2 ✓ |
def vedic_divisibility_test(num, divisor):
"""Check divisibility using Vedic methods."""
tests = {
9: lambda n: sum(int(d) for d in str(n)) % 9 == 0,
11: lambda n: abs(sum(int(d) for i, d in enumerate(str(n)) if i % 2 == 0) -
sum(int(d) for i, d in enumerate(str(n)) if i % 2 == 1)) % 11 == 0,
}
if divisor == 13:
n = num
while n > 99:
last = n % 10
n = n // 10 + last * 4
return n % 13 == 0
elif divisor == 17:
n = num
while n > 99:
last = n % 10
n = n // 10 - last * 5
return n % 17 == 0
elif divisor == 19:
n = num
while n > 99:
last = n % 10
n = n // 10 + last * 2
return n % 19 == 0
elif divisor in tests:
return tests[divisor](num)
else:
return num % divisor == 0
for num, div in [(1458, 9), (121, 11), (169, 13), (289, 17), (361, 19)]:
result = vedic_divisibility_test(num, div)
print(f"{num} divisible by {div}? {result}")Expected output:
1458 divisible by 9? True
121 divisible by 11? True
169 divisible by 13? True
289 divisible by 17? True
361 divisible by 19? TrueDecimal Division
Vedic methods extend to decimal places. To get decimal digits of a division:
def nikhilam_decimal(dividend, divisor, decimal_places=5):
"""Get decimal expansion using Nikhilam principles."""
q, r = nikhilam_divide(dividend, divisor)
result = f"{q}."
for _ in range(decimal_places):
r *= 10
digit, r = nikhilam_divide(r, divisor)
result += str(digit)
if r == 0:
break
return result
tests = [(1, 7), (1, 19), (22, 7)]
for d, div in tests:
res = nikhilam_decimal(d, div, 8)
print(f"{d}/{div} = {res}")Expected output:
1/7 = 0.14285714
1/19 = 0.05263157
22/7 = 3.14285714Speed Comparison: Vedic vs Traditional
import time
def traditional_divide(dividend, divisor):
return divmod(dividend, divisor)
def benchmark():
test_cases = [
(1032, 97),
(15234, 998),
(450000, 9985),
(1234567, 9992),
]
print(f"{'Problem':<18} {'Vedic (μs)':<12} {'Standard (μs)':<14} {'Speedup':<10}")
print("-" * 54)
for dividend, divisor in test_cases:
# Warm up
for _ in range(1000):
nikhilam_divide(dividend, divisor)
traditional_divide(dividend, divisor)
# Benchmark
start = time.perf_counter()
for _ in range(10000):
nikhilam_divide(dividend, divisor)
vedic_time = (time.perf_counter() - start) * 1e6 / 10000
start = time.perf_counter()
for _ in range(10000):
traditional_divide(dividend, divisor)
std_time = (time.perf_counter() - start) * 1e6 / 10000
speedup = std_time / vedic_time
print(f"{dividend}÷{divisor:<5} {vedic_time:<12.2f} {std_time:<14.2f} {speedup:<10.2f}x")
benchmark()Common Errors
- Wrong base selection — For divisor 97, base is 100 (not 1000). Choose the smallest power of 10 larger than the divisor.
- Deviation sign confusion — For divisor below base (like 97), deviation is positive. For divisor above base (like 103), deviation is negative. Sign matters in the multiplication step.
- Forgetting final adjustment — The Nikhilam process can leave a remainder >= divisor. Always check and adjust by subtracting the divisor.
- Applying Nikhilam to non-near-base divisors — Nikhilam works best when deviation < base/2. For larger deviations, use Paravartya or traditional division.
- Paravartya negative remainder handling — Transposed digits are negative, which can create negative intermediate remainders. Handle borrows carefully.
- Mixing up base for different divisor lengths — 1-digit divisor has base 10, 2-digit has base 100, 3-digit has base 1000. The split changes with each level.
- Paravartya when principal digit is 1 — Paravartya is simplest when the divisor’s first digit is 1 (like 123). For other first digits (like 312), divide by the principal first.
Practice Questions
- 2048 ÷ 96 = ? (Use Nikhilam, base 100)
- 54321 ÷ 999 = ?
- 1234 ÷ 111 = ? (Use Paravartya)
- 1000000 ÷ 9999 = ?
- Is 150368 divisible by 19?
Answers:
- 2048 ÷ 96: base 100, deviation 4. Split: 20 | 48 → 48 + 20×4 = 128 → 28 + 1×4 = 32 → Q=21, R=32. Check: 96×21=2016, 2048-2016=32 ✓
- 54321 ÷ 999: base 1000, deviation 1. Split: 54 | 321 → 321 + 54×1 = 375. Q=54, R=375. Check: 999×54=53946, 54321-53946=375 ✓
- 1234 ÷ 111: Q=11, R=13. Check: 111×11=1221, 1234-1221=13 ✓
- 1000000 ÷ 9999: base 10000, deviation 1. Split: 100 | 0000 → 0 + 100×1 = 100. Q=100, R=100. Check: 9999×100=999900, 1000000-999900=100 ✓
- 150368 ÷ 19: 15036 + 8×2 = 15052 → 1505 + 2×2 = 1509 → 150 + 9×2 = 168 → 16 + 8×2 = 32 → 32 ÷ 19 = 1 R 13. Not divisible. ✓
Mini Project: Division Method Selector
def recommend_method(divisor):
"""Recommend the best Vedic division method for a given divisor."""
base = 10 ** len(str(divisor))
deviation = base - divisor
deviation_ratio = deviation / base
if abs(deviation_ratio) < 0.2:
return "Nikhilam (near base)"
elif str(divisor)[0] == '1':
return "Paravartya Yojayet (transpose)"
elif divisor < 20:
return "Nikhilam (small divisor)"
else:
return "Standard division or Paravartya"
for divisor in [9, 97, 123, 312, 998, 101, 45]:
print(f"divisor {divisor}: → {recommend_method(divisor)}")Expected output:
divisor 9: → Nikhilam (near base)
divisor 97: → Nikhilam (near base)
divisor 123: → Paravartya Yojayet (transpose)
divisor 312: → Standard division or Paravartya
divisor 998: → Nikhilam (near base)
divisor 101: → Nikhilam (near base)
divisor 45: → Standard division or ParavartyaFAQ
Related Tutorials
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Updated 2026-06-20.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro