Even Or Odd

Easy
2 views 25 Jan 2026
Given an integer n, print EVEN or ODD....

Absolute Value

Easy
2 views 25 Jan 2026
Given an integer n, print its absolute value....

Sign Of Number

Easy
2 views 25 Jan 2026
Print NEGATIVE, ZERO, or POSITIVE for an integer n....

Last Digit

Easy
2 views 25 Jan 2026
Print the last digit of an integer n (as a non-negative digit)....

Divisible By 3

Easy
2 views 25 Jan 2026
Check if a number is divisible by 3 and print YES/NO....

Divisible By 9

Easy
2 views 25 Jan 2026
Check if a number is divisible by 9 and print YES/NO....

Divisible By 11

Medium
2 views 25 Jan 2026
Check divisibility by 11 using digit positions rule....

Divisible By 4 From Last Two Digits

Medium
2 views 25 Jan 2026
Given a decimal string s, decide if it represents a number divisible by 4....

Divisible By 8 From Last Three Digits

Medium
2 views 25 Jan 2026
Given a decimal string s, decide if it represents a number divisible by 8....

Divisible By 25

Easy
2 views 25 Jan 2026
Given integer n, print YES if divisible by 25....

Compare Fractions a/b and c/d

Hard
3 views 25 Jan 2026
Compare two fractions without floating point. Print , or =....

Floor And Ceil Division

Hard
3 views 25 Jan 2026
Given integers a and b>0, print floor(a/b) and ceil(a/b)....

Remainder Always Positive

Medium
3 views 25 Jan 2026
Given integers a and m>0, print a mod m in range [0,m-1]....

Round To Nearest Multiple

Hard
2 views 25 Jan 2026
Given n and k>0, round n to nearest multiple of k (ties go up)....

Count Multiples In Range

Medium
3 views 25 Jan 2026
Given L R k, count integers in [L,R] divisible by k....

Smallest Multiple >= N

Easy
3 views 25 Jan 2026
Given n and k>0, print the smallest multiple of k that is >= n....

Largest Multiple <= N

Easy
3 views 25 Jan 2026
Given n and k>0, print the largest multiple of k that is ...

Check Power Of Two

Medium
2 views 25 Jan 2026
Given n, print YES if it is a power of 2....

Nearest Power Of Two

Medium
3 views 25 Jan 2026
Given n>0, print the smallest power of 2 that is >= n....

Binary Length

Easy
3 views 25 Jan 2026
Given n>0, print how many bits are needed to write n in binary....

Digit Sum Mod 9

Medium
3 views 25 Jan 2026
Given a big number as string, print its digit sum modulo 9....

Digital Root

Medium
2 views 25 Jan 2026
Given a non-negative integer n (as string), print its digital root (0-9)....

Check Divisible By 6

Easy
2 views 25 Jan 2026
Given integer n, print YES if divisible by 6....

Check Divisible By 12

Medium
2 views 25 Jan 2026
Given integer n, print YES if divisible by 12....

Minimum Steps To Make Divisible

Medium
3 views 25 Jan 2026
Given n and k, find the smallest non-negative x so (n+x) divisible by k....

Reduce Ratio

Medium
2 views 25 Jan 2026
Given a and b, print the reduced ratio a:b....

Count Divisors Naive

Medium
2 views 25 Jan 2026
Given n...

Sum Of Divisors Naive

Hard
2 views 25 Jan 2026
Given n...

Perfect Number Check

Hard
3 views 25 Jan 2026
Check if n is a perfect number (sum of proper divisors equals n)....

Leap Year Simple

Easy
3 views 25 Jan 2026
Given year y, print YES if it is a leap year....

GCD Of Two Numbers

Easy
4 views 25 Jan 2026
Compute gcd(a,b)....

LCM Of Two Numbers

Easy
2 views 25 Jan 2026
Compute lcm(a,b)....

GCD Of Array

Medium
3 views 25 Jan 2026
Given n and n integers, print gcd of all numbers....

LCM Of Array Small

Hard
2 views 25 Jan 2026
Given n...

Are Coprime

Easy
2 views 25 Jan 2026
Print YES if gcd(a,b)=1....

Simplify Fraction

Medium
2 views 25 Jan 2026
Given a/b, reduce it to lowest terms and keep sign in numerator....

GCD Of Differences

Hard
2 views 25 Jan 2026
Given n numbers, print gcd of all |ai-a1|....

Extended Euclid Coefficients

Hard
3 views 25 Jan 2026
Find x,y such that ax+by=gcd(a,b). Print gcd x y....

Mod Inverse When Coprime

Hard
2 views 25 Jan 2026
Given a and m, print inverse of a mod m, or -1 if not exists....

LCM Using Prime Exponents

Hard
2 views 25 Jan 2026
Given two numbers ...

GCD Queries Prefix Suffix

Hard
2 views 25 Jan 2026
Given array and q queries [l,r], output gcd of all except between l..r....

Check If LCM Equals Product

Medium
3 views 25 Jan 2026
Given a and b, print YES if lcm(a,b)=a*b (no overlap factors)....

Count Coprime With N (Small)

Hard
2 views 25 Jan 2026
Given n...

Euler Totient By Factorization

Hard
3 views 25 Jan 2026
Given n...

Prime Check

Easy
2 views 25 Jan 2026
Print YES if n is prime....

Next Prime

Medium
2 views 25 Jan 2026
Given n, print the smallest prime >= n....

Smallest Prime Factor

Easy
2 views 25 Jan 2026
Given n>1, print its smallest prime factor....

Prime Factorization List

Medium
2 views 25 Jan 2026
Print prime factors with exponents for n....

Count Primes Up To N

Medium
3 views 25 Jan 2026
Given n...

Goldbach Pair (Even)

Hard
3 views 25 Jan 2026
Given even n (>=4), find two primes that sum to n....

Check Semiprime

Hard
2 views 25 Jan 2026
A semiprime has exactly two prime factors (counted with multiplicity). Print YES/NO....

Count Distinct Prime Factors

Medium
3 views 25 Jan 2026
Given n, print how many distinct primes divide it....

Squarefree Check

Hard
6 views 25 Jan 2026
Print YES if n is squarefree (no prime square divides it)....

Largest Prime Factor

Medium
2 views 25 Jan 2026
Print the largest prime factor of n....

Prime Gap Around N

Hard
2 views 25 Jan 2026
Given n, find nearest primes below and above (p...

Mod Normalize

Easy
2 views 25 Jan 2026
Given a and m>0, output normalized a mod m in [0,m-1]....

Add Mod M

Easy
2 views 25 Jan 2026
Compute (a+b) mod m for large a,b....

Subtract Mod M

Easy
2 views 25 Jan 2026
Compute (a-b) mod m (non-negative)....

Multiply Mod M

Hard
2 views 25 Jan 2026
Compute (a*b) mod m for up to 10^18 (use bigint idea)....

Fast Power Mod

Medium
2 views 25 Jan 2026
Compute a^b mod m....

Check Congruent

Easy
2 views 25 Jan 2026
Print YES if a and b are congruent mod m....

Solve x ≡ a (mod m) Range

Hard
2 views 25 Jan 2026
Find the smallest x in [L,R] such that x ≡ a mod m, else -1....

Chinese Remainder (Two)

Hard
2 views 25 Jan 2026
Solve x ≡ a (mod m), x ≡ b (mod n) when m and n are coprime....

Mod Inverse With Fermat

Medium
5 views 25 Jan 2026
Given prime p and a not divisible by p, compute inverse a^(p-2) mod p....

Count Solutions Of ax ≡ b (mod m)

Hard
2 views 25 Jan 2026
Count how many x in [0..m-1] satisfy ax ≡ b (mod m)....

Combinations nCr Small

Medium
2 views 25 Jan 2026
Compute nCr for small n (n...

Permutations nPr

Easy
2 views 25 Jan 2026
Compute nPr = n*(n-1)*...*(n-r+1)....

Count Binary Strings Without Consecutive 1s

Hard
3 views 25 Jan 2026
Given n, count length-n binary strings with no '11'....

Handshake Problem

Easy
2 views 25 Jan 2026
If there are n people and everyone shakes hands once, how many handshakes?...

Choose Team With Captain

Medium
2 views 25 Jan 2026
Choose r people from n and also pick a captain from chosen team....

Stars And Bars

Hard
2 views 25 Jan 2026
Count solutions of x1+...+xk = n with xi>=0....

Count Subsets Size K

Easy
2 views 25 Jan 2026
Given n and k, count k-sized subsets....

Binomial Identity Check

Medium
2 views 25 Jan 2026
Compute sum_{i=0..k} C(n,i) for given n,k....

Circular Arrangements

Easy
2 views 25 Jan 2026
Count ways to arrange n distinct items on a circle....

Derangements Small

Hard
2 views 25 Jan 2026
Compute number of derangements for n...

Probability Of Head Count

Hard
2 views 25 Jan 2026
Given n tosses, probability of exactly k heads as reduced fraction....

Expected Value Of Dice

Easy
2 views 25 Jan 2026
Expected sum of rolling one fair die....

At Least One Success

Hard
2 views 25 Jan 2026
Given n independent trials with success probability p (as a/b), find prob of at least one success....

Two Dice Sum Equals S

Medium
2 views 25 Jan 2026
Probability that sum of two fair dice equals S....

Conditional Probability Simple

Easy
2 views 25 Jan 2026
A bag has r red and b blue balls. One ball is drawn. Prob it is red....

Boolean Evaluate Expression

Medium
2 views 25 Jan 2026
Evaluate a boolean expression with AND/OR/NOT on 0/1 values....

De Morgan Apply

Easy
2 views 25 Jan 2026
Given X and Y (0/1), compute NOT(X AND Y) and (NOT X) OR (NOT Y) and verify equality....

XOR Basics

Easy
2 views 25 Jan 2026
Given bits a and b, print a XOR b....

Truth Table Count

Easy
2 views 25 Jan 2026
How many rows in truth table for n boolean variables?...

Implication Value

Medium
2 views 25 Jan 2026
Given bits p and q, compute p -> q....

Relation Reflexive Check

Medium
2 views 25 Jan 2026
Given n and a list of pairs (a,b), check if relation is reflexive....

Set Union Size

Easy
2 views 25 Jan 2026
Given sizes |A|,|B| and |A∩B|, compute |A∪B|....

Count Functions

Medium
2 views 25 Jan 2026
How many functions from set of size n to set of size m?...

Injective Functions Count

Hard
3 views 25 Jan 2026
Count injective functions from n to m (n...

Surjective Functions Small

Hard
2 views 25 Jan 2026
Count surjections from n to m for small n,m (...

Fibonacci n-th

Easy
3 views 25 Jan 2026
Compute the n-th Fibonacci number (0-indexed)....

Arithmetic Progression Term

Easy
2 views 25 Jan 2026
Given a1,d,n find n-th term....

Geometric Progression Term Mod

Medium
2 views 25 Jan 2026
Given a,r,n,m compute a*r^(n-1) mod m....

Solve Linear Recurrence

Hard
2 views 25 Jan 2026
Given f0,f1 and f(n)=f(n-1)+2f(n-2), compute f(n)....

Graph Handshaking Lemma

Easy
2 views 25 Jan 2026
Given degrees of all vertices, print YES if sum of degrees is even....

Edges From Degree Sum

Easy
2 views 25 Jan 2026
Given sum of degrees S, compute number of edges E....

Tree Edges

Easy
2 views 25 Jan 2026
Given number of nodes n in a tree, print number of edges....

Bipartite Complete Edges

Easy
2 views 25 Jan 2026
In complete bipartite K(a,b), how many edges?...

Catalan Number Cn

Hard
3 views 25 Jan 2026
Compute the n-th Catalan number for n...

Binary Tree Node Bounds

Medium
2 views 25 Jan 2026
Given height h (root at height 0), print min and max nodes in a binary tree....

Full Binary Tree Leaves

Easy
2 views 25 Jan 2026
In a full binary tree, leaves = internal+1. Given internal nodes i, print leaves....

2x2 Matrix Multiply

Medium
2 views 25 Jan 2026
Multiply two 2x2 matrices....

2x2 Determinant

Easy
2 views 25 Jan 2026
Compute determinant of 2x2 matrix....

Matrix Trace

Easy
2 views 25 Jan 2026
Given n and an n x n matrix, print its trace....

Dot Product

Easy
2 views 25 Jan 2026
Compute dot product of two vectors....

Angle Type By Dot Product

Medium
2 views 25 Jan 2026
Given two 2D vectors, print ACUTE/RIGHT/OBTUSE....

Distance Between Two Points

Easy
2 views 25 Jan 2026
Compute Euclidean distance between two points (x1,y1),(x2,y2) with 2 decimals....

Triangle Area By Shoelace

Medium
3 views 25 Jan 2026
Compute area of triangle from 3 points (2D)....

Floating Sum Stability

Hard
2 views 25 Jan 2026
Given n decimals, sum them and print with 6 decimals (show stable summation idea)....