An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Multiples and Least Common Multiple — Elementary Mathematics</title>
<link rel="stylesheet" href="../lib/engine.css">
<link rel="expect" href="#bar" blocking="render">
<style>.screen .blanks .line{gap:12px}.screen input.box{min-width:78px}</style>
</head>
<body>
<script src="../lib/engine.js"></script>
<script src="audio/en/timings.js"></script>
<script>
'use strict';
const CHAPTER = { number: 5, title: 'Multiples and Least Common Multiple', minutes: 10, language: 'en', next: '../ch06/' };
const MC_A=COL.whole,MC_B=COL.nat;
const mcText=(p,s,x,y,t=0,size=32,col=COL.chalk,anchor='start')=>{const e=T(p,s,{x,y,size,fill:col,anchor,o:0});show(e,t);return e;};
const mcMath=(p,s,x,y,t=0,size=44,col=COL.chalk,anchor='middle')=>{const e=M(p,[s],{x,y,size,fill:col,anchor,o:0});show(e,t);return e;};
function mcTitle(p,s,sub=''){mcText(p,s,100,120,.1,44);if(sub)mcText(p,sub,100,174,.25,27,COL.dim);}
function mcChip(p,v,x,y,t=0,col=COL.task,w=80){const g=G(p,{x,y,o:0});mk('rect',{x:-w/2,y:-30,width:w,height:60,rx:12,fill:COL.board,stroke:col,'stroke-width':2},g);T(g,String(v),{y:12,size:34,fill:col,anchor:'middle'});show(g,t);return g;}
function mcDots(p,n,cx,cy,cols,gap=35,col=COL.chalk,t=.2){const rows=Math.ceil(n/cols);return Array.from({length:n},(_,i)=>{const e=G(p,{x:cx+(i%cols-(cols-1)/2)*gap,y:cy+(Math.floor(i/cols)-(rows-1)/2)*gap,o:0});mk('circle',{r:9,fill:col},e);show(e,t+i*.015);return e;});}
function mcBundle(p,cx,cy,t){const g=G(p,{x:cx,y:cy,o:0});mk('rect',{x:-70,y:-70,width:140,height:140,rx:16,fill:'none',stroke:MC_A,'stroke-width':2.5},g);[-24,24].forEach(x=>[-24,24].forEach(y=>mk('circle',{cx:x,cy:y,r:11,fill:MC_A},g)));show(g,t);return g;}
function mcTrack(p,step,max,y,col,t=.2,{label='+'+step,arcs=true,ends=true}={}){
const x=v=>240+v/max*1160;const g=G(p);mcText(g,label,135,y+12,.2,36,col,'middle');
path(g,`M240 ${y}H1420`,{stroke:COL.faint,'stroke-width':2});
for(let v=0;v<=max;v++)path(g,`M${x(v)} ${y-5}V${y+5}`,{stroke:COL.faint,'stroke-width':1});
mcText(g,'0',240,y+48,.2,27,COL.dim,'middle');const points=[];
for(let v=step;v<=max;v+=step){const start=t+(v/step-1)*.25;
if(arcs)draw(path(g,`M${x(v-step)} ${y-10}Q${(x(v-step)+x(v))/2} ${y-85} ${x(v)} ${y-10}`,{stroke:col,'stroke-width':3,fill:'none'},{d:0}),start,.6);
const dot=G(g,{x:x(v),y,o:0});mk('circle',{r:9,fill:col},dot);show(dot,start+.4);
if(ends)mcText(g,String(v),x(v),y+48,start+.4,28,col,'middle');points.push({v,el:dot});
}
return {g,x,points};
}
function mcPairTracks(p,a,b,max,ta=.2,tb=.2,match=.2){
const A=mcTrack(p,a,max,310,MC_A,ta),B=mcTrack(p,b,max,475,MC_B,tb),shared=[];
for(let v=1;v<=max;v++)if(v%a===0&&v%b===0){const x=A.x(v);draw(path(p,`M${x} 327V330M${x} 374V457`,{stroke:COL.task,'stroke-width':3,'stroke-dasharray':'7 7'},{d:0}),match,.6);const el=mcChip(p,v,x,610,match+.4);shared.push({el,v,box:[x-46,572,92,77],label:`Shared positive endpoint ${v}`});}
return {A,B,shared};
}
function mcCoinGroups(dots,size,cy,t){const ng=dots.length/size,groupGap=1000/ng,inside=30;dots.forEach((e,i)=>{const k=Math.floor(i/size),j=i%size;tw(e,{x:800+(k-(ng-1)/2)*groupGap+(j-(size-1)/2)*inside,y:cy},t+i*.018,1.1,io);});}
const BEATS=[
['intro','Multiples and LCM',(m,D)=>{const g=G(scene,{o:0,y:24});T(g,'Unit 1 · The Number System · Chapter 5',{x:800,y:260,size:28,fill:COL.dim,anchor:'middle'});T(g,'Multiples and',{x:800,y:370,size:82,weight:600,anchor:'middle'});T(g,'Least Common Multiple',{x:800,y:470,size:76,weight:600,anchor:'middle'});tw(g,{o:1,y:0},.2,1.1,out);[4,6].forEach((n,i)=>mcDots(g,n,680+i*240,555,n,26,i?MC_B:MC_A,.8));const s=mcText(scene,'When will repeating patterns line up?',800,700,m('sub'),34,COL.dim,'middle');hide(g,D-.8,.7);hide(s,D-.8,.7);}],
['bundles','Build multiples from equal groups',m=>{const p=panel(0);mcTitle(p,'Grow the number of bundles','Every complete bundle holds 4 dots.');[350,650,950,1250].forEach((x,i)=>mcBundle(p,x,360,i?m(['one','two','three','four'][i]):.2));const keys=['one','two','three','four'];keys.forEach((key,i)=>{const g=G(p,{o:0}),x2=420+i*300;path(g,`M280 450v16h${x2-280}v-16`,{stroke:MC_A,'stroke-width':3});T(g,`${i+1} ${i?'bundles':'bundle'} so far`,{x:(280+x2)/2,y:515,size:30,fill:MC_A,anchor:'middle'});M(g,[`4 × ${i+1} = ${4*(i+1)}`],{x:800,y:605,size:52,fill:MC_A,anchor:'middle'});show(g,m(key));if(i<3)hide(g,m(keys[i+1]));});mcText(p,'4, 8, 12, 16, …',800,730,m('rule'),48,COL.task,'middle');mcText(p,'Each total is a whole number of complete bundles.',800,810,m('rule',2),31,COL.dim,'middle');}],
['hops','Equal jumps make multiples',m=>{const p=panel(0);mcTitle(p,'Multiples are equal-jump landing points','The track is drawn to scale: every tick is 1 unit.');mcTrack(p,4,24,425,MC_A,m('jump'));mcText(p,'4, 8, 12',800,610,m('jump',3),45,MC_A,'middle');mcText(p,'16, 20, 24',800,685,m('more'),45,MC_A,'middle');mcText(p,'Positive list starts at 4, not 0.',800,765,m('zero'),32,COL.task,'middle');mcText(p,'… another jump is always possible',800,825,m('endless'),30,COL.dim,'middle');}],
['q1','Quick check',()=>{const p=panel(0);mcTitle(p,'Which total is made of complete groups of 4?');S.mcBundles=[10,12,14].map((n,k)=>{const g=G(p);const cx=360+k*430;for(let j=0;j<Math.floor(n/4);j++)mcBundle(g,cx+(j-1)*100,370,.2);const dots=g.querySelectorAll('circle');dots.forEach(e=>e.setAttribute('r','7'));g.querySelectorAll('rect').forEach((e,j)=>{e.setAttribute('x',String(-45));e.setAttribute('width','90');e.setAttribute('y','-52');e.setAttribute('height','104');});if(n%4)mcDots(g,n%4,cx,490,2,38,COL.chalk,.3);mcText(g,`${n} dots`,cx,595,.3,34,COL.chalk,'middle');return {el:g,box:[cx-170,295,340,265],label:`${n} dots: ${Math.floor(n/4)} groups of four${n%4?' plus two leftovers':''}`};});},{ask:done=>quiz(BAND,[{id:'c-bundles',prompt:'Click the picture with no dots left outside its bundles.',build:pickEls(S.mcBundles,1,'12 = 3 × 4: three complete bundles, with no leftovers.',i=>`${i===0?10:14} leaves 2 dots outside the complete bundles. A multiple of 4 needs no leftovers.`,()=>pulseFx(S.mcBundles[1].el,1.1))}],done)}],
['common','Two patterns share endpoints',m=>{const p=panel(0);mcTitle(p,'Same scale. Different jump sizes.','Blue: groups of 4 Coral: groups of 6');mcPairTracks(p,4,6,24,m('four'),m('six'),m('match'));mcMath(p,'3 × 4 = 2 × 6 = 12',800,735,m('match',1),42,COL.task);mcText(p,'24 is shared too: 6 × 4 = 4 × 6',800,810,m('next'),32,COL.dim,'middle');}],
['least','Least means first positive match',m=>{const p=panel(0);mcTitle(p,'Read shared totals from smallest to largest');const q=mcPairTracks(p,4,6,24,.2,.2,.4);const first=q.shared[0].el;pulse(first,m('first'),1.25);draw(path(p,`M${q.A.x(12)-58} 565h116v90h-116Z`,{stroke:COL.task,'stroke-width':4},{d:0}),m('first'),.6);pulse(q.shared[1].el,m('later'),1.1);mcText(p,'0 = start; use positive totals',800,745,m('zero'),32,COL.dim,'middle');mcText(p,'LCM(4, 6) = 12',800,815,m('name'),46,COL.task,'middle');}],
['q2','Quick check',()=>{const p=panel(0);mcTitle(p,'Which shared endpoint is the least common multiple?');S.mcShared=mcPairTracks(p,4,6,24,.2,.2,.2).shared;},{ask:done=>quiz(BAND,[{id:'c-first',prompt:'Choose the first positive total reached by BOTH tracks.',build:pickEls(S.mcShared,0,'12 is the first positive match: 3 × 4 = 2 × 6.',()=> '24 works for both tracks, but 12 is a smaller positive match.',()=>pulseFx(S.mcShared[0].el,1.3))}],done)}],
['nines','Lists meet at ninety-nine',m=>{const p=panel(0);mcTitle(p,'Find the first shared value','Add the same group size at every step.');mcText(p,'9',110,350,.2,42,MC_A);mcText(p,'11',110,505,.2,42,MC_B);Array.from({length:11},(_,i)=>mcChip(p,9*(i+1),230+i*108,335,i?m('nine')+i*.22:.2,MC_A,72));const b=Array.from({length:9},(_,i)=>mcChip(p,11*(i+1),230+i*108,490,i?m('eleven')+i*.22:.2,MC_B,72));tw(b[8],{x:1310},m('match'),1,io);draw(path(p,'M1310 371V454',{stroke:COL.task,'stroke-width':4},{d:0}),m('match',1),.5);mcText(p,'81 → 90 → 99: do not skip a step',800,665,m('nine',3),32,COL.dim,'middle');mcText(p,'LCM(9, 11) = 99',800,780,m('match',1.5),48,COL.task,'middle');}],
['shortcut','Test the larger-number list',m=>{const p=panel(0);mcTitle(p,'One ordered list can do the job','Every candidate is already a multiple of 11.');const vals=Array.from({length:9},(_,i)=>11*(i+1));vals.forEach((v,i)=>{const x=i<5?300+i*245:800+(i-7.5)*245,y=i<5?335:520;const el=mcChip(p,v,x,y,i?m('start')+i*.12:.2,i===8?COL.task:MC_B,96);if(i<8)mcText(p,`÷9 → R ${v%9}`,x,y+72,m('test')+i*.25,30,COL.dim,'middle');else{pulse(el,m('whole'),1.2);mcText(p,'÷9 = 11 ✓',x,y+72,m('whole'),30,COL.task,'middle');}});mcMath(p,'99 ÷ 9 = 11',800,730,m('whole'),48,COL.task);mcText(p,'First candidate that passes both → LCM',800,815,m('stop'),34,COL.dim,'middle');}],
['divides','When one number divides the other',m=>{const p=panel(0);mcTitle(p,'What if the larger number already works?','Blue: groups of 6 Coral: groups of 18');mcPairTracks(p,6,18,36,.2,m('eighteen'),m('eighteen',1));mcMath(p,'18 = 3 × 6',750,730,m('eighteen',1.5),46,COL.task);mcText(p,'18 is the smallest positive multiple of 18.',800,795,m('small'),32,COL.dim,'middle');mcText(p,'LCM(6, 18) = 18',800,850,m('rule'),36,COL.task,'middle');}],
['triple','Common means every row',m=>{const p=panel(0);mcTitle(p,'Three group sizes: 3, 4, and 6');const a=mcTrack(p,3,12,290,MC_A,.2),b=mcTrack(p,4,12,460,MC_B,.2),c=mcTrack(p,6,12,630,COL.chalk,.2);const x=a.x(6);draw(path(p,`M${x} 355V605`,{stroke:COL.task,'stroke-width':2,'stroke-dasharray':'7 8'},{d:0}),m('six'),.5);mcText(p,'6 is not',1445,465,m('six',1),26,COL.task);mcText(p,'on this row',1445,497,m('six',1),26,COL.task);draw(path(p,'M1400 305V308M1400 354V478M1400 524V615',{stroke:COL.task,'stroke-width':4},{d:0}),m('twelve'),.6);mcText(p,'4 × 3 = 3 × 4 = 2 × 6 = 12',800,755,m('twelve'),39,COL.task,'middle');mcText(p,'LCM(3, 4, 6) = 12',800,825,m('all'),42,COL.task,'middle');}],
['schedule','The first shared inspection',m=>{const p=panel(0);mcTitle(p,'Two bikes. One shared inspection day.','Blue: inspect every 4 days Coral: inspect every 10 days');mcText(p,'start together',240,235,m('start'),27,COL.dim,'middle');mcPairTracks(p,4,10,20,m('five'),m('six'),m('meet'));mcText(p,'Day 20: 5 × 4 = 2 × 10',800,750,m('meet',1),44,COL.task,'middle');mcText(p,'20 days after their shared starting day',800,820,m('meet',3),32,COL.dim,'middle');}],
['q3','Quick check',()=>{const p=panel(0);mcTitle(p,'When do both bikes first need inspection together?','Blue: every 4 days. Coral: every 10 days.');const A=mcTrack(p,4,20,310,MC_A,.2),B=mcTrack(p,10,20,475,MC_B,.2);S.mcDays=[4,8,12,16,20].map(v=>{const el=mcChip(p,v,A.x(v),610,.4,COL.task,70);return {el,v,box:[A.x(v)-41,573,82,75],label:`Day ${v}`};});},{ask:done=>quiz(BAND,[{id:'c-reunion',prompt:'Pick the earliest positive day that appears on both inspection tracks.',build:pickEls(S.mcDays,4,'Day 20 is the first shared inspection: five 4-day periods, or two 10-day periods.',i=>`Day ${S.mcDays[i].v} is on the four-day track, but it is not divisible by 10.`,()=>pulseFx(S.mcDays[4].el,1.3))}],done)}],
['coins','The smallest equal total',m=>{const p=panel(0);mcTitle(p,'Equal totals. Different complete groups.','Blue collector: groups of 6 Coral collector: groups of 8');const demo=G(p);[[8,390,'8 = 6 + 2 left over',0],[16,590,'16 = 12 + 4 left over',2]].forEach(([n,cy,lab,dt])=>{mcDots(demo,n,520,cy,n,38,COL.chalk,m('eight')+dt);mcText(demo,lab,880,cy+12,m('eight')+dt+.4,32,COL.dim);});hide(demo,m('six'),.4);const aa=mcDots(p,24,800,390,24,36,MC_A,m('six')+.3),bb=mcDots(p,24,800,590,24,36,MC_B,m('six')+.3);mcCoinGroups(aa,6,390,m('six')+1.5);mcCoinGroups(bb,8,590,m('six')+1.5);[6,8].forEach((size,r)=>{const ng=24/size,cy=r?590:390;for(let k=0;k<ng;k++){const x=800+(k-(ng-1)/2)*1000/ng;const g=G(p,{o:0});mk('rect',{x:x-size*16,y:cy-36,width:size*32,height:72,rx:12,fill:'none',stroke:r?MC_B:MC_A,'stroke-width':2},g);show(g,m('six',3.4));}});mcText(p,'4 groups of 6 = 24',800,480,m('total'),32,MC_A,'middle');mcText(p,'3 groups of 8 = 24',800,680,m('total',1),32,MC_B,'middle');mcText(p,'24 coins for EACH collector',800,760,m('total',2),42,COL.task,'middle');mcText(p,'Smallest shared total, with no leftovers.',800,830,m('why'),31,COL.dim,'middle');}],
['wrap','Summary',m=>{const p=panel(0);[['Multiples: totals of complete equal groups.','w1'],['Common multiples: totals every group size can reach.','w2'],['LCM: first positive shared total.','w3'],['Use it: first reunions and smallest equal totals.','w4']].forEach(([s,k],i)=>{const g=G(p,{x:34,y:290+i*150,o:0});mk('circle',{cx:155,cy:-12,r:30,fill:COL.task},g);T(g,String(i+1),{x:155,y:0,size:34,fill:COL.board,anchor:'middle',weight:700});T(g,s,{x:215,size:44,weight:600});tw(g,{x:50,o:1},m(k),.6);});}],
['final1','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-lists',prompt:'Write the first five positive multiples, in increasing order.',build:blanks([{parts:['7: ',{box:'7'},', ',{box:'14'},', ',{box:'21'},', ',{box:'28'},', ',{box:'35'}],why:'Start with 7 × 1 = 7; add 7 each time.',hint:'Each next total is one more complete group of 7.'},{parts:['9: ',{box:'9'},', ',{box:'18'},', ',{box:'27'},', ',{box:'36'},', ',{box:'45'}],why:'Start with 9 × 1 = 9; add 9 each time.',hint:'Start with one group, then add 9 at each step.'}])}],done,'Chapter practice · set 1 of 3')}],
['final2','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-lcm',prompt:'Find each least common multiple.',build:blanks([{parts:['LCM(6, 10) = ',{box:'30'}],why:'10,20,30… first divides exactly by 6 at 30.'},{parts:['LCM(8, 12) = ',{box:'24'}],why:'8,16,24… meets 12,24… at 24.'},{parts:['LCM(10, 15) = ',{box:'30'}],why:'15,30… first divides exactly by 10 at 30.'},{parts:['LCM(7, 28) = ',{box:'28'}],why:'28 itself is 4 × 7; no smaller positive multiple of 28 exists.'}])}],done,'Chapter practice · set 2 of 3')}],
['final3','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[
{id:'p-visits',prompt:'Two friends start together. One visits a community workshop every 3 days, the other every 5 days. Find their first shared return.',build:blanks([{parts:[{box:'15'},' days after the start'],why:'LCM(3,5) = 15: five 3-day periods and three 5-day periods.'}])},
{id:'p-packages',prompt:'Two shops receive equal positive item totals. One receives complete packages of 4 items, the other packages of 10. What is the least total for each?',build:blanks([{parts:[{box:'20'},' items each'],why:'LCM(4,10) = 20: five packages of four or two packages of ten.'}])},
{id:'p-flowers',prompt:'Ana and Ben have equal positive flower totals. Ana makes bouquets of 5, Ben bouquets of 9, with no leftovers. Find the least total for each.',build:blanks([{parts:[{box:'45'},' flowers each'],why:'LCM(5,9) = 45 flowers: Ana has 9 bouquets, Ben 5. Flowers and bouquets are different units.'}])}
],done,'Chapter practice · set 3 of 3')}],
['finish','Finished',()=>panel(0),{ask:finishCard}]
].map(([id,title,run,extra])=>({id,title,run,...extra}));
boot();
</script>
</body>
</html>