# Complete Sequences and Magic Tricks

DevFeed: [Complete Sequences and Magic Tricks](<https://devfeed.tech/articles/complete-sequences-and-magic-tricks-40288.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2012/10/02/complete-sequences-and-magic-tricks/>)

Published: 2012-10-02T11:28:16Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Sequences](<https://devfeed.tech/topics/sequences.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Code](<https://devfeed.tech/topics/code.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [code](<https://devfeed.tech/tags/code.md>), [dynamic-programming](<https://devfeed.tech/tags/dynamic-programming.md>), [greedy-algorithm](<https://devfeed.tech/tags/greedy-algorithm.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [numberphile](<https://devfeed.tech/tags/numberphile.md>), [primes](<https://devfeed.tech/tags/primes.md>), [programming](<https://devfeed.tech/tags/programming.md>), [sequences](<https://devfeed.tech/tags/sequences.md>)

## AI overview

This tutorial explains complete integer sequences through a card trick inspired by a Numberphile video. It presents a greedy algorithm that generates the cards and selects the smallest representation of each number, then shows how to implement the method in JavaScript.

## Source excerpt

Numberphile posted a video today describing a neat trick based on complete sequences: The mathematics here is pretty simple, but I noticed at the end of the video that Dr. Grime was constructing the cards by hand, when really this is a job for a computer program. I thought it would be a nice warmup exercise (and a treat to all of the Numberphile viewers) to write a program to construct the cards for any complete sequence.