Skip to content

Instantly share code, notes, and snippets.

@edrex
Created February 27, 2012 02:34
Show Gist options
  • Select an option

  • Save edrex/1920883 to your computer and use it in GitHub Desktop.

Select an option

Save edrex/1920883 to your computer and use it in GitHub Desktop.
Pascal's Triangle Congruence Mod p
<!DOCTYPE html>
<meta charset="utf-8">
<title>Pascal's Triangle Congruence Mod p</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/2.7.4/d3.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.1/underscore-min.js"></script>
<link href="style.css" media="screen" rel="stylesheet" type="text/css" />
<body>
<div style="float:right; text-align: right">
<form id='form'>
<p>
<label for="max">Maximum rows:</label>
<input type="number" value="64" min="1" max=500 id="n">
</p>
<p>
<label for="max">P (base for mod):</label>
<input type="number" value="11" min="1" max=500 id="p">
</p>
<input type="submit" id="generate">Generate!</input>
</form>
</div>
<script src="pascal.js" type="text/javascript"></script>
<script>
function render() {
make_vis_svg(d3.select("#n").property("value"),
d3.select("#p").property("value"));
}
render();
var form = d3.select("#form")
.on("submit", function() {
render()
d3.event.preventDefault()
});
</script>
body {
margin: 0 40px;
}
form#form {
font-size: small;
}
circle:hover {
cursor:crosshair;
fill: red ! important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment