Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


        <link rel="stylesheet" type="text/css" href="assets/stylesheets/css/main.css">
        <div class="tdc-grid"></div>

        <script src="assets/js/jquery-3.2.1.min.js"></script>
        <script src="assets/js/underscore.js"></script>
        <script src="assets/js/sieve.js"></script>



                .tdc-grid {
    &-item {
        display: inline-block;
        float: left;
        margin: 5px;
        padding: 10px;
        width: 30px;
        border-radius: 2px;
        text-align: center;
        background: #c5d8fc;
        color: white;
        box-shadow: 0 0 1px 1px rgba(0,0,0,.1);

        &.active {
            background: #7ca7f8;



                // Up to which number would you like to see the preceding primes?
let limit = 1000;

    grid: '.tdc-grid',
    grid_item: 'tdc-grid-item'

let CLASSES = {
    active: 'active'

* Return a list of primes (or non_primes) up to a certain limit
let sieve = (lim) => {
    let primes = [];
    let non_primes = [];

    for(let number = 2; number < Math.sqrt(lim); number++) {
        if(!_.contains(non_primes, number)) {
            for(let unmarked = Math.pow(number, 2); unmarked < lim; unmarked += number) {

    non_primes = _.sortBy(_.uniq(non_primes), n => n);

    return _.filter(_.range(2, lim), n => !_.contains(non_primes, n));

* Draw as many grid items as set in the parameters
let drawGrid = (lim) => {
    _.each(_.range(2, lim), number => {
        $(SELECTORS.grid).append(`<div class="${SELECTORS.grid_item} number-${number}"> ${number} </div>`);

* Give each prime number an active class to distinguish
let drawPrimes = (primes) => {
    _.each(primes, prime => {