Everything on the site.

Big-O notationAlgorithms · Count the steps in real loops, then compare n, n log n, n² and 2ⁿ on a live chart.RecursionAlgorithms · Watch frames push and pop on the call stack for factorial and Fibonacci.BFS vs DFSAlgorithms · A queue against a stack: draw a graph and see which order each search visits it in.Sorting algorithmsAlgorithms · Seven sorts on the same input, with comparison, swap and write counts side by side.Binary searchAlgorithms · Halve the range, probe the middle, repeat: with lo, mid and hi drawn on the array.Sets, relations and functionsDiscrete maths · Shade any set expression on a Venn diagram and test a relation for its properties.Proof by inductionDiscrete maths · Four worked proofs revealed one step at a time, and a broken one to diagnose.CombinatoricsDiscrete maths · An exact nPr and nCr calculator, and a Pascal’s triangle that shows its own addition rule.Boolean algebraDiscrete maths · The laws, De Morgan, and normal forms, with a truth-table generator built in.Finite-state machinesTheory · Build a DFA in a table, see it drawn, and run strings through it one symbol at a time.Domain theoryTheory · Why recursion needs least fixed points, and how CPOs, Scott continuity and powerdomains supply them.Truth table generatorTools · Expression in, truth table out: with DNF, CNF, a minimal form and LaTeX.Graph traversal visualiserTools · Draw a graph, then animate BFS, DFS and Dijkstra with the frontier shown.Recursion tree visualiserTools · Paste a recursive function or a recurrence and see its call tree and call count.Gradient descentML maths · Drag the starting point, set the learning rate, and watch it converge or blow up.Vectors and embeddingsML maths · Bend the plane with a 2×2 matrix and measure how close toy word vectors are.Softmax and cross-entropyML maths · Edit the logits and watch the probabilities, the loss and the gradient update live.Attention mechanismML maths · Q, K and V for three tokens, a live score heatmap, and the weighted sum of values.Formatting a CS paper in LaTeXLaTeX · Page limits, \documentclass, front matter, theorem environments and the bibliography.Camera-ready checklistLaTeX · Fonts embedded, PDF/A, copyright form, source bundle, and why final versions get rejected.LaTeX templatesLaTeX · Where the official classes live, plus a minimal article template you can copy.Boolean algebra calculatorTools · A Boolean expression simplifier that names the law used at every step.K-map solverTools · Fill in a Karnaugh map and see the groups, the minimal SOP and POS, and the essential terms.Logic gate simulatorTools · Wire up gates, flip the switches, and get the truth table and expression of your circuit.Regex to NFA converterTools · Type a regular expression and watch Thompson’s construction build its NFA, fragment by fragment.NFA to DFA converterTools · Enter an NFA or a regex and step through the subset construction, then minimise the DFA.DFA simulatorTools · Edit a DFA, run strings through it step by step, batch-test them and share the machine as a link.Regular expressions to automataTheory · Regex to NFA to DFA to minimal DFA, worked through on one example with every set shown.The halting problemTheory · Why no program can tell whether every program halts, with the paradox program played out.Pigeonhole principleDiscrete maths · n pigeons, k holes: why some hole gets ⌈n/k⌉, and the surprising things that follows from it.Dijkstra’s algorithmAlgorithms · Shortest paths with a priority queue: a worked table, a proof, and a graph you can redraw.Hash functionsAlgorithms · Keys in, buckets out: hash a word four ways, then watch chaining and probing handle collisions.Sorting algorithm visualizerTools · Up to seven sorts race on the same data, then step through any one of them line by line.LaTeX table generatorTools · Type or paste a table, merge cells, pick booktabs, and copy clean tabular code.Combination calculatorTools · Exact nCr with the cancelling shown, combinations with repetition, and a full list for small n.Permutation calculatorTools · nPr, nʳ, anagrams like MISSISSIPPI and round-table seatings, with exact working.AlgorithmsSection · Step-through visualisations of sorting, searching, recursion, graph traversal, Dijkstra’s algorithm, hash functions and Big-O growth, with pseudocode that follows along.Discrete mathsSection · Sets, relations and functions, proof by induction, counting, the pigeonhole principle and Boolean algebra, explained with worked examples and interactive checkers.TheorySection · Finite-state machines, regular expressions and automata, the halting problem, and the mathematical semantics of programming languages, explained from first principles.ML mathsSection · Gradient descent, vectors and embeddings, softmax and cross-entropy, and attention, each with a formula, a worked numeric example and a live version.ToolsSection · Free browser tools: truth tables, Boolean simplification, K-maps, logic gates, nCr and nPr, regex to NFA to DFA, sorting and graph visualisers, and LaTeX tables.LaTeXSection · How to format a CS conference or workshop paper in LaTeX, a camera-ready checklist, and a minimal template you can adapt.
Free tool

Permutation calculator (nPr) with step-by-step working

Count the ways to arrange r items chosen from n when the order matters. The calculator gives exact values of nPr with the working shown, and covers the other three permutation questions that come up most: repetition allowed, words with repeated letters, and seating around a circle.

Interactive: nPr calculator with four modes and a list of arrangementsUpdated

Permutation calculator (nPr)

Step-by-step working

    List the arrangements

    The permutation formula

    A permutation is an ordered arrangement. The number of ways to arrange rr items chosen from nn distinct items, without repeats, is

    P(n,r)=nPr=n!(n−r)!=n×(n−1)×⋯×(n−r+1).P(n, r) = {}^{n}P_{r} = \frac{n!}{(n-r)!} = n \times (n-1) \times \cdots \times (n-r+1).

    The right-hand form shows where it comes from. There are nn choices for the first position. Whatever you picked, n−1n-1 items are left for the second, then n−2n-2, and so on until all rr positions are filled. The product rule multiplies these together. When r=nr = n, every item is placed and the count is n!n!, because 0!=10! = 1.

    Worked example: gold, silver and bronze among 8 runners

    1. Order matters (gold then silver is not silver then gold) and no runner can win two medals, so use P(8,3)P(8, 3).
    2. Formula: P(8,3)=8!5!P(8, 3) = \dfrac{8!}{5!}.
    3. Cancel 5!5!: keep the top three factors, 8×7×68 \times 7 \times 6.
    4. Multiply: 336 possible podiums.

    Four kinds of arrangement

    The calculator has a mode for each of these. Picking the right one is most of the work.

    1. No repetition: nPr

    Distinct items, each used at most once. Five people standing in a line: 5!5! = 120. Electing a president, a secretary and a treasurer from a club of 20: P(20,3)P(20, 3) = 6840. Compare that with choosing an unranked committee of three, which is a combination: (203)\binom{20}{3} = 1140. The ratio is exactly 3!=63! = 6, the number of ways to hand out three different roles to the same three people.

    2. Repetition allowed: n to the power r

    When an item can be used again, every position has all nn choices: nrn^r. A four-digit PIN has 10410^4 = 10,000 possibilities. A number plate with three letters followed by four digits: 263×10426^3 \times 10^4 = 175,760,000. Strictly speaking these are sequences or “words” rather than permutations, but calculators and exam papers usually list them under permutations with repetition.

    3. Repeated identical items: anagrams

    How many different words can be made from the letters of MISSISSIPPI? If all 11 letters were different there would be 11!11! orders. But swapping two of the S’s gives the same word. The four I’s can be permuted among themselves in 4!4! ways, the four S’s in 4!4!, and the two P’s in 2!2!, without changing anything. So divide those out:

    11!1! 4! 4! 2!=34,650.\frac{11!}{1!\,4!\,4!\,2!} = 34{,}650.

    In general, for nn items in groups of identical items of sizes n1,n2,…,nkn_1, n_2, \dots, n_k, the number of distinct arrangements is the multinomial coefficient

    n!n1! n2!⋯nk!.\frac{n!}{n_1!\, n_2! \cdots n_k!}.

    BANANA has one B, three A’s and two N’s, so it has 6!/(1! 3! 2!)6!/(1!\,3!\,2!) = 60 arrangements; the calculator lists all of them. MISSISSIPPI has 34,650. Type comma-separated items instead of a word to count arrangements of anything else, such as red, red, blue, green.

    4. Around a circle

    Six people at a round table. In a row there are 6!6! orders, but moving everyone one seat to the left gives the same seating, since each person has the same neighbours. Each circular seating appears 6 times among the row orders, once per rotation, so there are 6!/6=5!6!/6 = 5! = 120. In general nn people fit around a circle in (n−1)!(n-1)! ways, and choosing rr of nn to seat gives P(n,r)/rP(n, r)/r.

    Clockwise and anticlockwise versions still count as different here: the people on your left and right swap. For a necklace or key ring that can be turned over, they are the same, so halve the answer (for r≥3r \ge 3).

    Which mode? Can an item be used twice? Use with repetition. Are some items identical to each other? Use anagrams. Is the arrangement a ring with no first position? Use circle. Otherwise use nPr. And if the order doesn’t matter at all, you want a combination instead.

    Arrangements with conditions

    Many exam questions add a rule. Two techniques handle most of them.

    Glue items together. How many ways can 3 maths, 4 physics, 2 chemistry and 3 biology books stand on a shelf if each subject stays together? Treat each subject as one block: 4!4! orders of the blocks. Then arrange the books inside each block: 3! 4! 2! 3!3!\,4!\,2!\,3!. The product is 1728.

    Subtract the arrangements you don’t want. How many ways can 5 people stand in a line if Ana and Ben must not be next to each other? All orders: 5!=1205! = 120. Orders with them together: glue them into one block, 4!4! orders, times 2 for the order inside the block, giving 48. So 120−48=72120 - 48 = 72.

    How large factorials get

    Factorials grow faster than any exponential. 10!10! is about 3.6 million, 20!20! already exceeds 2×10182 \times 10^{18}, and the number of ways to shuffle a 52-card deck is 52!52! ≈ 8.0658×10678.0658 \times 10^{67}, a 68-digit number. Ordinary calculators switch to rounded scientific notation long before that. This one uses exact BigInt arithmetic in your browser and prints every digit, with the scientific form alongside once a value reaches ten digits.

    The growth matters in computer science: a brute-force search that tries every ordering of nn items, such as the naive solution to the travelling-salesperson problem, does n!n! work and becomes hopeless around n=15n = 15. The same count gives the Ω(nlog⁡n)\Omega(n \log n) lower bound for comparison sorting, explained on the sorting algorithms page: a sort must tell all n!n! input orders apart.

    References

    1. K. H. Rosen, Discrete Mathematics and Its Applications, 8th ed., McGraw-Hill, 2019. Sections 6.3 (permutations) and 6.5 (permutations with indistinguishable objects).
    2. R. L. Graham, D. E. Knuth and O. Patashnik, Concrete Mathematics, 2nd ed., Addison-Wesley, 1994. Sections 4.4 and 5.1.
    3. “Permutation”, Wikipedia.