Python math exercises
Number problems in Python, from digits and primes to counting, each checked by tests in your browser.
Beginner
- 29. Digital RootSqueeze a huge number down to a single digit30 XP5 min
- 210. Armstrong Number153 has a secret hidden in its own digits30 XP5 min
- 218. Greatest Common DivisorThe biggest square tile that covers a floor with no cutting30 XP5 min
- 224. Reverse an IntegerRead a number from right to left, minus sign and all30 XP5 min
- 241. Perfect NumberSix is perfect, and so is 28: is your number one of them?35 XP7 min
- 246. Triangle TypeThree sticks: what kind of triangle do they make, if any?35 XP6 min
Intermediate
- 72. Primes Up to NEvery prime number, all the way up to a limit65 XP12 min
- 87. Trailing Zeros of a FactorialHow many zeros sit at the end of a gigantic number?70 XP10 min
- 88. Convert Between BasesTranslate a number from one counting system to another75 XP14 min
- 272. Least Common Multiple of a ListEvery bus left the depot at six. When do they all leave together again?60 XP10 min
- 280. Count the DivisorsIn how many ways can the chairs be set out in neat rows?65 XP10 min
- 286. Prime FactorsBreak a number down into the primes it is built from65 XP12 min
- 291. The Nth PrimeWhich prime stands ten-thousandth in line?65 XP12 min
- 315. Catalan NumbersHow many ways can brackets pair up without tangling?75 XP15 min
- 323. Right Triangles With Whole SidesThe 3-4-5 triangle has many cousins: find them all75 XP15 min
Advanced
- 154. Fraction to Recurring DecimalWrite any fraction as a decimal, even the ones that never end140 XP30 min
- 349. Egyptian FractionsWrite any fraction the way the scribes of ancient Egypt did120 XP20 min
- 359. Next Bigger NumberShuffle the digits to get the very next number up125 XP20 min
- 364. Decimal to FractionTurn any decimal, even one that repeats forever, back into a fraction130 XP25 min
- 382. Binomial Coefficients Modulo a PrimeAnswer thousands of how-many-ways questions in the blink of an eye140 XP25 min
- 385. Fibonacci of a Huge IndexJump straight to the billion-billionth Fibonacci number140 XP25 min
- 406. Dice Sum ProbabilityRoll a fistful of dice: how likely is that exact total?150 XP30 min
- 415. Primes in a WindowHow many primes live between two numbers near a billion?150 XP30 min
- 426. The Chinese Remainder PuzzleCounted in threes, fives and sevens: how many coins are in the pile?160 XP30 min
Expert
- 183. Digits in Page NumbersA book with a billion billion pages: how often is one digit printed?230 XP45 min
- 437. Sum of Floor DivisionsCount every divisor of every number up to a trillion200 XP30 min
- 443. Digit Sums Over a RangeAdd up every digit of every number between two giants220 XP40 min
- 459. Path in the Stern-Brocot TreeEvery positive fraction has an address in one endless tree230 XP45 min
- 464. Count the Perfect PowersSquares, cubes and higher powers, all the way to a billion billion240 XP45 min
- 475. K-th Number in Dictionary OrderSort a billion numbers like words and pick one out250 XP45 min
- 499. Sum of Euler's TotientHow many fractions between 0 and 1 have a small denominator?280 XP60 min
Other topics
- Python Basics
- Strings
- Lists
- Dictionaries and sets
- Loops
- Functions
- Sorting and searching
- Two pointers
- Sliding window
- Stacks and queues
- Recursion and backtracking
- Dynamic programming
- Greedy
- Graphs
- Trees
- Bit manipulation
- Classes
- Iterators and generators
- Parsing
- Simulation
- Python idioms
- Regular expressions
- Codes and ciphers
- Working with data
- Grids and matrices
- Geometry
- Games and puzzles
- Heaps
- Data structures
Or see every challenge, with study plans, today's challenge and duels.