Math calculators

Pre Algebra Calculator

Updated Sep 9, 2026 By Jehan Wadia
Rate Formulas
div>'; g.innerHTML=h; Array.prototype.slice.call(g.querySelectorAll('input[type="radio"]')).forEach(function(inp){ inp.addEventListener('change',function(){ state.methodIdx=parseInt(this.value,10)||0; renderSteps(); renderAlt(); katexRender(); }); }); } function renderSteps(){ var sol=state.sol,html=''; if(sol&&sol.methods&&sol.methods.length){ var m=sol.methods[state.methodIdx]||sol.methods[0]; if(sol.methods.length>1) html+='
'+esc(m.name)+'
'; m.steps.forEach(function(st,i){ html+=stepHtml(st,i+1); }); } if(!html) html='
No worked steps are needed for this result.
'; document.getElementById('stepsContainer').innerHTML=html; } function renderAlt(){ var sol=state.sol,card=$('paAltCard'),body=$('paAltBody'),others=[]; if(sol&&sol.methods) sol.methods.forEach(function(m,i){ if(i!==state.methodIdx) others.push(m); }); if(!others.length){ card.style.display='none'; body.innerHTML=''; return; } card.style.display=''; var html=''; others.forEach(function(m){ html+='
'+esc(m.name)+'
'; m.steps.forEach(function(st,i){ html+=stepHtml(st,i+1); }); }); body.innerHTML=html; } /* ================= number line ================= */ function niceStep(x){ if(!(x>0)) return 1; var p=Math.pow(10,Math.floor(Math.log(x)/Math.LN10)),f=x/p,n=f<=1?1:f<=2?2:f<=5?5:10; return n*p; } function fmtTick(t){ return ''+(Math.round(t*1e6)/1e6); } function clearNlTimers(){ nlTimers.forEach(function(t){ clearTimeout(t); }); nlTimers=[]; } function renderNumberLine(spec){ clearNlTimers(); var card=$('paNlCard'); if(!spec){ card.style.display='none'; $('paNl').innerHTML=''; $('paNlDesc').textContent=''; return; } card.style.display=''; var min=spec.min,max=spec.max; if(!(max>min)){ min=min-5; max=max+5; } var W=640,pad=36,sx=function(x){ return pad+(x-min)/(max-min)*(W-2*pad); },step=niceStep((max-min)/10),t; var s=''; s+=''; s+=''; s+=''; for(t=Math.ceil(min/step)*step;t<=max+1e-9;t+=step){ var X=sx(t),zero=Math.abs(t)<1e-9; s+=''; s+=''+esc(fmtTick(t))+''; } if(spec.ray){ var x0=sx(spec.ray.from),x1=spec.ray.dir>0?(W-pad-8):(pad+8),ax=spec.ray.dir>0?(x1+12):(x1-12); s+=''; s+=''; } (spec.points||[]).forEach(function(p){ var X=sx(p.x); s+=''; s+=''+esc(p.label)+''; }); s+=''; $('paNl').innerHTML=s; $('paNlDesc').textContent=spec.desc||''; } function nlPlay(){ clearNlTimers(); var els=Array.prototype.slice.call($('paNl').querySelectorAll('.pa-anim')); if(!els.length) return; var reduce=window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches; if(reduce){ els.forEach(function(e){ e.style.opacity=''; }); return; } els.forEach(function(e){ e.style.opacity='0'; }); els.forEach(function(e,i){ nlTimers.push(setTimeout(function(){ e.style.opacity=''; },380*(i+1))); }); } function nlStop(){ clearNlTimers(); Array.prototype.slice.call($('paNl').querySelectorAll('.pa-anim')).forEach(function(e){ e.style.opacity=''; }); } /* ================= chart ================= */ function renderChart(spec){ var card=$('paChartCard'); if(!spec||typeof ApexCharts==='undefined'){ card.style.display='none'; if(chartObj){ chartObj.destroy(); chartObj=null; } return; } card.style.display=''; $('paChartTitle').textContent=spec.title||'Visualization'; var C=['#1f1280','#4caf50','#FF9800','#f44336','#4937d6'],opts; if(spec.type==='donut'){ opts={series:spec.series,labels:spec.labels,chart:{type:'donut',height:330,toolbar:{show:false}},colors:C, legend:{position:'bottom',labels:{colors:'#333'}},dataLabels:{enabled:true,style:{fontSize:'12px',colors:['#fff']}}, tooltip:{y:{formatter:function(v){ return nfmt(v); }}}}; } else if(spec.type==='line'){ opts={series:spec.series,chart:{type:'line',height:340,toolbar:{show:false}},colors:C,stroke:{width:3,curve:'straight'}, markers:{size:spec.series.length>1?4:0},dataLabels:{enabled:false}, xaxis:{type:'numeric',title:{text:spec.xtitle||'x',style:{color:'#333'}},labels:{style:{colors:'#333'},formatter:function(v){ return nfmt(parseFloat(v)); }}}, yaxis:{title:{text:spec.ytitle||'y',style:{color:'#333'}},labels:{style:{colors:'#333'},formatter:function(v){ return nfmt(v); }}}, legend:{labels:{colors:'#333'}},tooltip:{y:{formatter:function(v){ return nfmt(v); }}}}; } else { opts={series:spec.series,chart:{type:'bar',height:330,toolbar:{show:false}},colors:C, plotOptions:{bar:{columnWidth:'55%',borderRadius:4,distributed:!!spec.distributed}}, xaxis:{categories:spec.categories,labels:{style:{colors:'#333'}}}, yaxis:{labels:{style:{colors:'#333'},formatter:function(v){ return nfmt(v); }}}, legend:{show:false},dataLabels:{enabled:true,style:{colors:['#fff'],fontSize:'12px'},formatter:function(v){ return nfmt(v); }}, tooltip:{y:{formatter:function(v){ return nfmt(v); }}}}; } if(chartObj){ chartObj.destroy(); chartObj=null; } $('paChart').innerHTML=''; try{ chartObj=new ApexCharts($('paChart'),opts); chartObj.render(); }catch(e){ card.style.display='none'; } } /* ================= verification ================= */ function normText(s){ return String(s).toLowerCase().replace(/\s+/g,'') .replace(/[\u00D7\u00B7\u2219]/g,'*').replace(/\u00F7/g,'/') .replace(/\u2264/g,'<=').replace(/\u2265/g,'>=') .replace(/[\u2013\u2014\u2212]/g,'-').replace(/[{}]/g,'').replace(/\.$/,''); } function evalUser(raw){ try{ var tk=fixup(tokenize(raw)),i; for(i=0;iCorrect! Your answer matches the solution.
' : '
Not quite \u2014 review the steps above and try again.
'; } /* ================= UI data ================= */ var DEFAULT_INPUT='3 + 6 \u00D7 (5 + 4) \u00F7 3 \u2212 7'; var CATS=[ {id:'ooo',name:'Order of Operations',subs:[ {id:'ooo_two',name:'Two-step with parentheses',ph:'e.g. (8 + 4) \u00F7 2'}, {id:'ooo_multi',name:'Multi-step without parentheses',ph:'e.g. 5 + 3 \u00D7 4 \u2212 6 \u00F7 2'}, {id:'ooo_full',name:'PEMDAS / BODMAS full expression',ph:'e.g. 3 + 6 \u00D7 (5 + 4) \u00F7 3 \u2212 7'}]}, {id:'int',name:'Integers & Arithmetic',subs:[ {id:'int_add',name:'Addition',ph:'e.g. -14 + 27'}, {id:'int_sub',name:'Subtraction',ph:'e.g. -8 \u2212 (-15)'}, {id:'int_mul',name:'Multiplication',ph:'e.g. -12 \u00D7 7'}, {id:'int_div',name:'Division (long division)',ph:'e.g. long division 144 \u00F7 12'}, {id:'int_mixed',name:'Mixed operations with negatives',ph:'e.g. -3 \u00D7 (4 \u2212 9) + 6'}]}, {id:'fac',name:'Factors & Primes',subs:[ {id:'pf_prime',name:'Prime factorization',ph:'e.g. prime factors of 45'}, {id:'pf_factors',name:'List all factors',ph:'e.g. factors of 36'}, {id:'pf_gcf2',name:'GCF (two numbers)',ph:'e.g. gcf(18, 24)'}, {id:'pf_gcf3',name:'GCF (three or more)',ph:'e.g. gcf(12, 18, 30)'}, {id:'pf_lcm2',name:'LCM (two numbers)',ph:'e.g. lcm(6, 12)'}, {id:'pf_lcm3',name:'LCM (three or more)',ph:'e.g. lcm(3, 4, 6)'}]}, {id:'fr',name:'Fractions',subs:[ {id:'fr_simplify',name:'Simplify fraction',ph:'e.g. simplify 4/8'}, {id:'fr_compare',name:'Compare fractions',ph:'e.g. compare 3/5 and 5/8'}, {id:'fr_addsub',name:'Add / subtract fractions',ph:'e.g. 1/2 + 1/4 + 3/4'}, {id:'fr_muldiv',name:'Multiply / divide fractions',ph:'e.g. 2/3 \u00D7 9/10'}, {id:'fr_mixed',name:'Mixed number conversion',ph:'e.g. 4 5/8 as an improper fraction'}, {id:'fr_improper',name:'Improper to mixed',ph:'e.g. 37/8 as a mixed number'}]}, {id:'dp',name:'Decimals & Percents',subs:[ {id:'dp_d2f',name:'Decimal to fraction',ph:'e.g. 0.48 as a fraction'}, {id:'dp_f2d',name:'Fraction to decimal',ph:'e.g. 3/8 as a decimal'}, {id:'dp_p2d',name:'Percent to decimal',ph:'e.g. 45% as a decimal'}, {id:'dp_d2p',name:'Decimal to percent',ph:'e.g. 0.35 as a percent'}, {id:'dp_pof',name:'Percent of a number',ph:'e.g. 75% of 200'}, {id:'dp_pch',name:'Percent change',ph:'e.g. percent change from 50 to 75'}]}, {id:'er',name:'Exponents & Radicals',subs:[ {id:'er_exp',name:'Evaluate exponent',ph:'e.g. 4^2 \u00B7 4^2'}, {id:'er_sqrt',name:'Square root',ph:'e.g. sqrt(144)'}, {id:'er_nth',name:'Nth root',ph:'e.g. nthroot(3, 64)'}, {id:'er_sci',name:'Scientific notation',ph:'e.g. 45000 in scientific notation'}]}, {id:'rp',name:'Ratios & Proportions',subs:[ {id:'rp_simp',name:'Simplify ratio',ph:'e.g. simplify ratio 12:18'}, {id:'rp_solve',name:'Solve proportion',ph:'e.g. 3:4 = x:20'}, {id:'rp_unit',name:'Unit rate',ph:'e.g. 120 miles in 2 hours'}]}, {id:'eq',name:'Equations',subs:[ {id:'eq_one',name:'One-step equation',ph:'e.g. x + 5 = 11'}, {id:'eq_two',name:'Two-step equation',ph:'e.g. 3x + 2 = 23'}, {id:'eq_ineq1',name:'Inequality (one-step)',ph:'e.g. x + 5 \u2264 14'}, {id:'eq_ineq2',name:'Inequality (two-step)',ph:'e.g. 2x \u2212 3 > 7'}]}, {id:'nl',name:'Number Line',subs:[ {id:'nl_plot',name:'Plot a value',ph:'e.g. plot -3'}, {id:'nl_cmp',name:'Compare two values',ph:'e.g. compare -2 and 5'}, {id:'nl_ineq',name:'Plot an inequality',ph:'e.g. x > 3'}]}, {id:'ef',name:'Expanded Form',subs:[ {id:'ef_s2e',name:'Standard to expanded',ph:'e.g. expanded form of 3452'}, {id:'ef_e2s',name:'Expanded to standard',ph:'e.g. 3000 + 400 + 50 + 2'}]}, {id:'mo',name:'Modulo',subs:[ {id:'mod_basic',name:'Basic modulo operation',ph:'e.g. 17 mod 5'}]} ]; var EXAMPLES=['prime factors of 45','lcm(6, 12)','gcf(18, 24)','x + 5 = 11','3x + 2 = 23','x + 5 \u2264 14','4^2 \u00B7 4^2','simplify 4/8', '1/2 + 1/4 + 3/4','4 5/8','75% of 200','3:4 = x:20','-21 = -3x','3 + 6 \u00D7 (5 + 4) \u00F7 3 \u2212 7','0.48 as a fraction', '17 mod 5','expanded form of 3452','120 miles in 2 hours','sqrt(144)','45000 in scientific notation']; var QUICK=[ {l:'GCF',t:'pf_gcf2',x:'gcf(18, 24)'},{l:'LCM',t:'pf_lcm2',x:'lcm(6, 12)'},{l:'Factors',t:'pf_factors',x:'factors of 36'}, {l:'Simplify',t:'fr_simplify',x:'simplify 4/8'},{l:'Long Division',t:'int_div',x:'long division 144 \u00F7 12'}, {l:'Scientific Notation',t:'er_sci',x:'45000 in scientific notation'}]; var MORE=[ {l:'Prime Factors',t:'pf_prime',x:'prime factors of 45'},{l:'Proportions',t:'rp_solve',x:'3:4 = x:20'}, {l:'Order of Operations',t:'ooo_full',x:'3 + 6 \u00D7 (5 + 4) \u00F7 3 \u2212 7'},{l:'Number Line',t:'nl_plot',x:'plot -3'}, {l:'Percent',t:'dp_pof',x:'75% of 200'},{l:'Modulo',t:'mod_basic',x:'17 mod 5'},{l:'Square Root',t:'er_sqrt',x:'sqrt(144)'}, {l:'Mixed Number',t:'fr_mixed',x:'4 5/8 as an improper fraction'},{l:'Ratio',t:'rp_simp',x:'simplify ratio 12:18'}, {l:'Equation Solver',t:'eq_two',x:'3x + 2 = 23'},{l:'Inequalities',t:'eq_ineq1',x:'x + 5 \u2264 14'}, {l:'Expanded Form',t:'ef_s2e',x:'expanded form of 3452'}]; var ALLQUICK=QUICK.concat(MORE); var SYMKEYS=[ {l:'x2',i:'^2',a:'squared'},{l:'x^\u25A1',i:'^',a:'exponent'},{l:'\u221A\u25A1',i:'sqrt(',a:'square root'}, {l:'\u207F\u221A\u25A1',i:'nthroot(3,',a:'nth root'},{l:'|\u25A1|',i:'abs(',a:'absolute value'},{l:'\u25A1/\u25A1',i:'/',a:'fraction bar'}, {l:'\u25A1 \u25A1/\u25A1',i:' ',a:'mixed number space'},{l:'\u00B7',i:'*',a:'multiply'},{l:'\u00F7',i:'\u00F7',a:'divide'}, {l:'\u03C0',i:'pi',a:'pi'},{l:'\u2264',i:'<=',a:'less than or equal to'},{l:'\u2265',i:'>=',a:'greater than or equal to'}, {l:'\u2260',i:'!=',a:'not equal to'},{l:'log',i:'log(',a:'logarithm base ten'},{l:'log\u25A1',i:'logb(2,',a:'logarithm with a chosen base'}]; var GRID=[ {l:'7',i:'7',a:'seven'},{l:'8',i:'8',a:'eight'},{l:'9',i:'9',a:'nine'},{l:'\u00D7',i:'*',a:'times',c:'op'},{l:'(',i:'(',a:'open parenthesis',c:'op'}, {l:'4',i:'4',a:'four'},{l:'5',i:'5',a:'five'},{l:'6',i:'6',a:'six'},{l:'\u00F7',i:'\u00F7',a:'divided by',c:'op'},{l:')',i:')',a:'close parenthesis',c:'op'}, {l:'1',i:'1',a:'one'},{l:'2',i:'2',a:'two'},{l:'3',i:'3',a:'three'},{l:'+',i:'+',a:'plus',c:'op'},{l:'^',i:'^',a:'exponent',c:'op'}, {l:'0',i:'0',a:'zero'},{l:'.',i:'.',a:'decimal point'},{l:'(-)',i:'-',a:'negative sign',c:'op'},{l:'\u2212',i:'-',a:'minus',c:'op'},{l:'=',i:' = ',a:'equals',c:'op'}]; var VARKEYS=[{l:'x',i:'x',a:'variable x'},{l:'y',i:'y',a:'variable y'},{l:'n',i:'n',a:'variable n'}, {l:'\u232B Backspace',k:'bs',a:'backspace',c:'util'},{l:'Clear',k:'clr',a:'clear the field',c:'util'}]; var TABS=[ {name:'Algebra',keys:[{l:'a',i:'a',a:'a'},{l:'b',i:'b',a:'b'},{l:'c',i:'c',a:'c'},{l:'d',i:'d',a:'d'},{l:'k',i:'k',a:'k'},{l:'m',i:'m',a:'m'}, {l:'p',i:'p',a:'p'},{l:'t',i:'t',a:'t'},{l:'x',i:'x',a:'x'},{l:'y',i:'y',a:'y'},{l:'z',i:'z',a:'z'}, {l:'<',i:'<',a:'less than',c:'op'},{l:'>',i:'>',a:'greater than',c:'op'},{l:'\u2264',i:'<=',a:'less than or equal to',c:'op'}, {l:'\u2265',i:'>=',a:'greater than or equal to',c:'op'},{l:'\u2260',i:'!=',a:'not equal to',c:'op'},{l:'=',i:' = ',a:'equals',c:'op'}, {l:'|\u25A1|',i:'abs(',a:'absolute value'},{l:'\u25A1!',i:'!',a:'factorial'},{l:'(',i:'(',a:'open parenthesis',c:'op'},{l:')',i:')',a:'close parenthesis',c:'op'}]}, {name:'Fractions & Mixed',keys:[{l:'\u25A1/\u25A1',i:'/',a:'fraction bar'},{l:'\u25A1 \u25A1/\u25A1',i:' ',a:'mixed number space'}, {l:'1/2',i:'1/2',a:'one half'},{l:'1/3',i:'1/3',a:'one third'},{l:'1/4',i:'1/4',a:'one quarter'},{l:'3/4',i:'3/4',a:'three quarters'}, {l:'2/5',i:'2/5',a:'two fifths'},{l:'5/8',i:'5/8',a:'five eighths'}, {l:'simplify',i:'simplify ',a:'simplify keyword'},{l:'as an improper fraction',i:' as an improper fraction',a:'as an improper fraction'}, {l:'as a mixed number',i:' as a mixed number',a:'as a mixed number'},{l:'compare',i:'compare ',a:'compare keyword'}]}, {name:'Long Arithmetic',keys:[{l:'\u25AD + \u25AD',i:' + ',a:'long addition'},{l:'\u25AD \u2212 \u25AD',i:' - ',a:'long subtraction'}, {l:'\u25AD \u00D7 \u25AD',i:' * ',a:'long multiplication'},{l:'\u25AD \u00F7 \u25AD',i:' \u00F7 ',a:'long division'}, {l:'long division',i:'long division ',a:'long division keyword'},{l:'mod',i:' mod ',a:'modulo'}, {l:'expanded form of',i:'expanded form of ',a:'expanded form keyword'}]}, {name:'Exponents & Roots',keys:[{l:'x2',i:'^2',a:'squared'},{l:'x3',i:'^3',a:'cubed'},{l:'xn',i:'^',a:'exponent'}, {l:'\u221A',i:'sqrt(',a:'square root'},{l:'\u221B',i:'cbrt(',a:'cube root'},{l:'\u207F\u221A',i:'nthroot(3,',a:'nth root'}, {l:'10x',i:'10^',a:'ten to a power'},{l:'ex',i:'2.718281828^',a:'e to a power'}, {l:'scientific notation',i:' in scientific notation',a:'scientific notation keyword'}]}, {name:'Greek & Symbols',keys:[{l:'\u03C0',i:'pi',a:'pi'},{l:'\u221E',i:'\u221E',a:'infinity'},{l:'\u00B0',i:'\u00B0',a:'degree'}, {l:'\u03B1',i:'\u03B1',a:'alpha'},{l:'\u03B2',i:'\u03B2',a:'beta'},{l:'\u03B8',i:'\u03B8',a:'theta'},{l:'\u0394',i:'\u0394',a:'delta'}, {l:'\u03BC',i:'\u03BC',a:'mu'},{l:':',i:':',a:'ratio colon'},{l:'%',i:'%',a:'percent'},{l:'$',i:'$',a:'dollar sign'}]} ]; /* ================= UI builders ================= */ function targetEl(){ return state.target||$('paInput'); } function insert(txt){ var el=targetEl(),start=el.selectionStart,end=el.selectionEnd,v=el.value; if(typeof start!=='number'){ el.value=v+txt; } else { el.value=v.slice(0,start)+txt+v.slice(end); var p=start+txt.length; try{ el.setSelectionRange(p,p); }catch(e){} } el.focus(); updatePreview(el); } function backspace(){ var el=targetEl(),start=el.selectionStart,end=el.selectionEnd,v=el.value; if(typeof start!=='number'){ el.value=v.slice(0,-1); } else if(start!==end){ el.value=v.slice(0,start)+v.slice(end); try{ el.setSelectionRange(start,start); }catch(e){} } else if(start>0){ el.value=v.slice(0,start-1)+v.slice(start); try{ el.setSelectionRange(start-1,start-1); }catch(e){} } el.focus(); updatePreview(el); } function keyBtn(k){ return ''; } function buildTypeUI(){ var cb=$('paCatBar'),h=''; CATS.forEach(function(c){ h+=''; }); cb.innerHTML=h; cb.addEventListener('click',function(e){ var b=e.target.closest?e.target.closest('button[data-cat]'):null; if(!b) return; Array.prototype.slice.call(cb.querySelectorAll('button')).forEach(function(x){ x.classList.remove('active'); x.setAttribute('aria-expanded','false'); }); b.classList.add('active'); var id=b.getAttribute('data-cat'); if(id==='auto'){ state.cat=null; state.type='auto'; $('paSubBar').innerHTML=''; $('paSelLabel').textContent='Auto-detect (general)'; $('paInput').placeholder='Enter a math problem, or use the keyboard below\u2026'; return; } b.setAttribute('aria-expanded','true'); state.cat=id; buildSubBar(id); }); $('paSubBar').addEventListener('click',function(e){ var b=e.target.closest?e.target.closest('button[data-sub]'):null; if(!b) return; Array.prototype.slice.call($('paSubBar').querySelectorAll('button')).forEach(function(x){ x.classList.remove('active'); }); b.classList.add('active'); state.type=b.getAttribute('data-sub'); $('paSelLabel').textContent=b.getAttribute('data-name'); $('paInput').placeholder=b.getAttribute('data-ph'); }); } function buildSubBar(catId){ var c=null; CATS.forEach(function(x){ if(x.id===catId) c=x; }); if(!c) return; var h=''; c.subs.forEach(function(s){ h+=''; }); var bar=$('paSubBar'); bar.innerHTML=h; bar.setAttribute('aria-label',c.name+' sub-types'); } function setType(id){ state.type=id; var found=null,cat=null; CATS.forEach(function(c){ c.subs.forEach(function(s){ if(s.id===id){ found=s; cat=c; } }); }); if(!found){ state.type='auto'; $('paSelLabel').textContent='Auto-detect (general)'; return; } Array.prototype.slice.call($('paCatBar').querySelectorAll('button')).forEach(function(x){ var on=(x.getAttribute('data-cat')===cat.id); x.classList.toggle('active',on); x.setAttribute('aria-expanded',on?'true':'false'); }); buildSubBar(cat.id); $('paSelLabel').textContent=cat.name+' \u2192 '+found.name; $('paInput').placeholder=found.ph; } function openMenu(){ $('paSeeAllMenu').hidden=false; $('paSeeAll').setAttribute('aria-expanded','true'); } function closeMenu(){ $('paSeeAllMenu').hidden=true; $('paSeeAll').setAttribute('aria-expanded','false'); } function applyQuick(q){ if(!q) return; setType(q.t); $('paInput').value=q.x; updatePreview($('paInput')); calculate(); $('paInput').focus(); } function buildQuick(){ var bar=$('paQuickBar'),h=''; QUICK.forEach(function(q,i){ h+=''; }); bar.innerHTML=h; bar.addEventListener('click',function(e){ var b=e.target.closest?e.target.closest('button[data-q]'):null; if(b) applyQuick(QUICK[parseInt(b.getAttribute('data-q'),10)]); }); var menu=$('paSeeAllMenu'),mh=''; ALLQUICK.forEach(function(q,i){ mh+=''; }); menu.innerHTML=mh; menu.addEventListener('click',function(e){ var b=e.target.closest?e.target.closest('button[data-m]'):null; if(!b) return; applyQuick(ALLQUICK[parseInt(b.getAttribute('data-m'),10)]); closeMenu(); $('paSeeAll').focus(); }); menu.addEventListener('keydown',function(e){ var items=Array.prototype.slice.call(menu.querySelectorAll('button')),i=items.indexOf(document.activeElement); if(e.key==='ArrowDown'){ e.preventDefault(); items[(i+1+items.length)%items.length].focus(); } else if(e.key==='ArrowUp'){ e.preventDefault(); items[(i-1+items.length)%items.length].focus(); } else if(e.key==='Home'){ e.preventDefault(); items[0].focus(); } else if(e.key==='End'){ e.preventDefault(); items[items.length-1].focus(); } else if(e.key==='Escape'){ e.preventDefault(); closeMenu(); $('paSeeAll').focus(); } }); $('paSeeAll').addEventListener('click',function(){ if($('paSeeAllMenu').hidden) openMenu(); else closeMenu(); }); $('paSeeAll').addEventListener('keydown',function(e){ if(e.key==='ArrowDown'){ e.preventDefault(); openMenu(); var f=$('paSeeAllMenu').querySelector('button'); if(f) f.focus(); } else if(e.key==='Escape'){ closeMenu(); } }); document.addEventListener('click',function(e){ var m=$('paSeeAllMenu'),t=$('paSeeAll'); if(!m.hidden&&!m.contains(e.target)&&!t.contains(e.target)) closeMenu(); }); } function selectTab(btn,focus){ var tabs=Array.prototype.slice.call($('paKbTabs').querySelectorAll('[role="tab"]')); tabs.forEach(function(t,i){ var on=(t===btn); t.setAttribute('aria-selected',on?'true':'false'); t.tabIndex=on?0:-1; var pan=$('papan'+i); if(pan) pan.hidden=!on; }); if(focus&&btn) btn.focus(); } function buildKeyboard(){ $('paSymRow').innerHTML=SYMKEYS.map(keyBtn).join(''); $('paNumGrid').innerHTML=GRID.map(keyBtn).join(''); $('paVarRow').innerHTML=VARKEYS.map(keyBtn).join(''); $('paMiniSym').innerHTML=SYMKEYS.slice(0,9).map(keyBtn).join(''); $('paMiniGrid').innerHTML=GRID.map(keyBtn).join(''); var t='',p=''; TABS.forEach(function(tb,i){ t+=''; p+='
'+tb.keys.map(keyBtn).join('')+'
'; }); $('paKbTabs').innerHTML=t; $('paKbPanels').innerHTML=p; $('paKbTabs').addEventListener('click',function(e){ var b=e.target.closest?e.target.closest('[role="tab"]'):null; if(b) selectTab(b); }); $('paKbTabs').addEventListener('keydown',function(e){ var tabs=Array.prototype.slice.call($('paKbTabs').querySelectorAll('[role="tab"]')),i=tabs.indexOf(document.activeElement); if(i<0) return; if(e.key==='ArrowRight'){ e.preventDefault(); selectTab(tabs[(i+1)%tabs.length],true); } else if(e.key==='ArrowLeft'){ e.preventDefault(); selectTab(tabs[(i-1+tabs.length)%tabs.length],true); } else if(e.key==='Home'){ e.preventDefault(); selectTab(tabs[0],true); } else if(e.key==='End'){ e.preventDefault(); selectTab(tabs[tabs.length-1],true); } }); } function buildExamples(){ var box=$('paExamples'),list=state.showAllEx?EXAMPLES:EXAMPLES.slice(0,8),h=''; list.forEach(function(x){ h+=''; }); box.innerHTML=h; } /* ================= main ================= */ function calculate(){ var raw=$('paInput').value,err=$('paError'); var sol=solveAll(raw,state.type); if(!sol||sol.error){ err.style.display=''; err.textContent=(sol&&sol.error)||'I could not solve that problem.'; return; } err.style.display='none'; err.textContent=''; state.sol=sol; state.methodIdx=0; renderAnswer(sol); renderMethods(sol); renderSteps(); renderAlt(); renderNumberLine(sol.numberLine); renderChart(sol.chart); $('paVerifyStatus').innerHTML=''; $('paVerifyHint').textContent=sol.hint||''; if(!firstPaint&&window.katex){ document.querySelectorAll('#calculator-wrapper .katexReplace').forEach(function(el){ if(el.querySelector('.katex')) return; var src=el.getAttribute('data-tex'); if(src===null||src===undefined){ src=el.textContent; el.setAttribute('data-tex',src); } try{ katex.render(src,el,{throwOnError:false}); }catch(e){} }); } } function resetAll(){ state.type='auto'; state.cat=null; state.methodIdx=0; $('paInput').value=DEFAULT_INPUT; $('paSubBar').innerHTML=''; Array.prototype.slice.call($('paCatBar').querySelectorAll('button')).forEach(function(x){ var on=(x.getAttribute('data-cat')==='auto'); x.classList.toggle('active',on); x.setAttribute('aria-expanded','false'); }); $('paSelLabel').textContent='Auto-detect (general)'; $('paInput').placeholder='Enter a math problem, or use the keyboard below\u2026'; $('paVerifyInput').value=''; $('paVerifyStatus').innerHTML=''; $('paImgStatus').innerHTML=''; updatePreview($('paInput')); updatePreview($('paVerifyInput')); calculate(); } function wireEvents(){ $('calcBtn').addEventListener('click',calculate); $('resetBtn').addEventListener('click',resetAll); $('paVerifyBtn').addEventListener('click',verify); $('paClearBtn').addEventListener('click',function(){ $('paInput').value=''; updatePreview($('paInput')); $('paInput').focus(); }); $('paCamBtn').addEventListener('click',function(){ $('paFile').click(); }); $('paFile').addEventListener('change',function(){ var f=this.files&&this.files[0]; this.value=''; if(!f) return; var rd=new FileReader(); rd.onload=function(ev){ $('paImgStatus').innerHTML='
'+ 'Preview of the uploaded problem image'+ 'Image loaded. This tool runs entirely in your browser, so it cannot read the picture for you \u2014 type or tap the problem into the field above, then press Solve.'+ '
'; var c=$('paImgClear'); if(c) c.addEventListener('click',function(){ $('paImgStatus').innerHTML=''; $('paCamBtn').focus(); }); }; rd.readAsDataURL(f); }); ['paInput','paVerifyInput'].forEach(function(id){ var el=$(id); el.addEventListener('focus',function(){ state.target=el; }); el.addEventListener('input',function(){ updatePreview(el); }); el.addEventListener('keydown',function(e){ if(e.key==='Enter'){ e.preventDefault(); if(id==='paInput') calculate(); else verify(); } }); }); $('paRoot').addEventListener('click',function(e){ var b=e.target.closest?e.target.closest('.pa-key'):null; if(!b) return; var act=b.getAttribute('data-act'); if(act==='bs') backspace(); else if(act==='clr'){ var el=targetEl(); el.value=''; updatePreview(el); el.focus(); } else insert(b.getAttribute('data-ins')||''); }); $('paExamples').addEventListener('click',function(e){ var b=e.target.closest?e.target.closest('button[data-ex]'):null; if(!b) return; $('paInput').value=b.getAttribute('data-ex'); state.target=$('paInput'); updatePreview($('paInput')); calculate(); }); $('paMoreEx').addEventListener('click',function(){ state.showAllEx=!state.showAllEx; this.setAttribute('aria-expanded',state.showAllEx?'true':'false'); this.textContent=state.showAllEx?'Show Less':'Show More'; buildExamples(); }); $('paKbToggle').addEventListener('click',function(){ state.full=!state.full; this.setAttribute('aria-pressed',state.full?'true':'false'); this.textContent=state.full?'Compact Keyboard':'Full Keyboard'; $('paFullPanel').style.display=state.full?'':'none'; }); $('paStepsToggle').addEventListener('click',function(){ var open=this.getAttribute('aria-expanded')==='true'; this.setAttribute('aria-expanded',open?'false':'true'); $('stepsContainer').style.display=open?'none':''; this.textContent=open?'Show Steps':'Hide Steps'; }); $('paAltToggle').addEventListener('click',function(){ var open=this.getAttribute('aria-expanded')==='true'; this.setAttribute('aria-expanded',open?'false':'true'); $('paAltBody').style.display=open?'none':''; this.textContent=open?'Show Steps':'Hide Steps'; }); $('paNlPlay').addEventListener('click',nlPlay); $('paNlStop').addEventListener('click',nlStop); } /* ================= init (runs on page load) ================= */ buildTypeUI(); buildQuick(); buildKeyboard(); buildExamples(); wireEvents(); state.target=$('paInput'); updatePreview($('paInput')); updatePreview($('paVerifyInput')); calculate(); firstPaint=false; setTimeout(function(){ var sc=$('stepsContainer'); if(window.katex&&sc&&!sc.querySelector('.katex')) katexRender(); updatePreview($('paInput')); },900); })();

Introduction

The Pre Algebra Calculator solves math problems and shows you every step. Type a problem like 3 + 6 × (5 + 4) ÷ 3 − 7, press Solve, and you get the answer plus a step-by-step explanation you can follow.

This free pre algebra solver covers the topics you see in class:

You can pick a problem type or let the tool detect it for you. A built-in math keyboard types fractions, exponents, roots, and symbols, so you do not have to hunt for keys. Some problems also show a second method, so you can learn more than one way to solve them.

Charts and number lines make the math easier to picture. To test yourself, type your own answer in the Check Your Answer box and see if it matches. Use it for homework, to check work you already did, and to see how each type of pre algebra problem is solved.

How to use our Pre Algebra Calculator

Type a math problem, pick a problem type if you want, and press Solve. The calculator shows the answer, step-by-step work, and a number line or chart when it helps.

Problem type: Leave it on Auto-detect, or click a category like Fractions or Equations and then pick the sub-type, such as "Add / subtract fractions."

Quick topic buttons: Click a chip like GCF, LCM, or Long Division to load a ready example. Click "See all" for more topics, like percent, ratios, and number line.

Math problem box: Type your problem here, like 3 + 6 × (5 + 4) ÷ 3 − 7 or gcf(18, 24). Press Enter or click Solve. Use the Clear button to empty the box.

Math keyboard: Tap the keys to add numbers, signs, fractions, roots, and variables. Click "Full Keyboard" to open extra tabs for algebra, fractions, exponents, and Greek symbols.

Example problems: Click any example to load it and solve it right away. Click "Show More" to see the full list.

Image upload: Click the camera button to add a photo of your problem for reference. The tool cannot read the picture, so type the problem in the box.

Method choice: If more than one way works, pick a method with the radio buttons. The steps change to match your pick, and the other method shows under "Another Way."

Show or hide steps: Click "Hide Steps" to see just the answer, or "Show Steps" to see the full work again.

Number line: Click Play to watch the points and arrows appear, and Stop to show them all at once.

Check your answer: Type your own answer in the last box and click Verify. The tool tells you if it matches the correct solution.

What Is Pre-Algebra?

Pre-algebra is the math you learn between basic arithmetic and algebra. It takes the skills you already know, like adding, subtracting, multiplying, and dividing, and gets them ready for problems that use letters like x and y. Most students study pre-algebra in grades 6 through 8.

Main Pre-Algebra Topics

  • Order of operations (PEMDAS/BODMAS): Do parentheses first, then exponents, then multiply and divide from left to right, then add and subtract from left to right.
  • Integers: Positive and negative whole numbers. Two negatives multiplied make a positive. Subtracting a negative is the same as adding.
  • Factors and primes: Prime factorization, listing factors, GCF (greatest common factor), and LCM (least common multiple).
  • Fractions: Simplifying, comparing, adding with a common denominator, multiplying across, and dividing by flipping the second fraction.
  • Decimals and percents: Moving between 0.35, 35%, and 7/20, plus percent of a number and percent change.
  • Exponents and roots: Repeated multiplication, square roots, nth roots, and scientific notation for very big or very small numbers.
  • Ratios and proportions: Comparing amounts, finding unit rates, and cross-multiplying to solve for a missing value.
  • Equations and inequalities: Undoing operations to get the variable alone. Remember: flip the inequality sign when you multiply or divide by a negative.
  • Number lines and expanded form: Seeing where numbers sit in order and breaking a number into place values, like 3452 = 3000 + 400 + 50 + 2.

Why Pre-Algebra Matters

Pre-algebra is the base for algebra, geometry, and every math class after that. It also shows up in daily life: splitting a bill, finding a sale price, doubling a recipe, or checking a unit price at the store.

Tips for Getting It Right

  • Write each step on its own line so mistakes are easy to spot.
  • Keep track of negative signs. They cause most errors.
  • Do the same thing to both sides of an equation to keep it balanced.
  • Check your answer by plugging it back into the original problem.
  • Reduce fractions to lowest terms before you call the work done.

Formulas used

Least common multiple from the greatest common factor
\operatorname{lcm}(a,b)=\frac{|a\cdot b|}{\gcd(a,b)}
Simplifying a fraction
\frac{a}{b}=\frac{a\div g}{b\div g},\quad g=\gcd(a,b)
Adding or subtracting fractions
\frac{a}{b}\pm\frac{c}{d}=\frac{a\,d\pm b\,c}{b\,d}
Mixed number to improper fraction
a\,\frac{b}{c}=\frac{a\cdot c+b}{c}
Percent of a number
P\%\text{ of }N=\frac{P}{100}\cdot N
Percent change from old to new value
\text{change}=\frac{V_{\text{new}}-V_{\text{old}}}{|V_{\text{old}}|}\times 100\%
Solving a proportion for x
\frac{a}{b}=\frac{x}{d}\;\Longrightarrow\;x=\frac{a\cdot d}{b}
Solving a two-step linear equation
ax+b=c\;\Longrightarrow\;x=\frac{c-b}{a}

Frequently asked questions

What does PEMDAS stand for?

PEMDAS is the order you follow when a problem has more than one operation:

  • P: Parentheses
  • E: Exponents
  • MD: Multiply and Divide, left to right
  • AS: Add and Subtract, left to right

Other countries use BODMAS or BIDMAS. They mean the same thing.

Do you always multiply before you divide?

No. Multiplication and division are equal in rank, so you work from left to right. In 12 ÷ 3 × 2, you divide first (12 ÷ 3 = 4), then multiply (4 × 2 = 8). Addition and subtraction follow the same left-to-right rule.

What grade is pre-algebra taught in?

Most students take pre-algebra in 7th or 8th grade. Some schools start parts of it in 6th grade, and advanced students may finish it earlier so they can take Algebra 1 sooner.

What is the difference between pre-algebra and algebra?

Pre-algebra works mostly with numbers: fractions, decimals, percents, integers, and simple equations like x + 5 = 11. Algebra works with letters and rules: writing expressions, graphing lines, factoring, and solving harder equations with variables on both sides.

Why does a negative times a negative equal a positive?

A negative sign means "the opposite of." So −3 × −4 means the opposite of (3 × −4), which is the opposite of −12, or +12. Quick rule: same signs give a positive answer, different signs give a negative answer.

What is the difference between GCF and LCM?

The GCF (greatest common factor) is the biggest number that divides into both numbers. The LCM (least common multiple) is the smallest number both numbers divide into.

For 6 and 8: GCF = 2, LCM = 24. Use GCF to simplify fractions and LCM to find common denominators.

How do you find the LCM of two numbers?

Two easy ways:

  • List multiples: 6 → 6, 12, 18, 24. 8 → 8, 16, 24. The first match is 24.
  • Use the GCF: LCM = (a × b) ÷ GCF. For 6 and 8: (48) ÷ 2 = 24.

Is 1 a prime number?

No. A prime number has exactly two different factors: 1 and itself. The number 1 has only one factor, so it is neither prime nor composite. The smallest prime number is 2, and it is the only even prime.

How do you add fractions with different denominators?

Find a common denominator, usually the LCM of the bottom numbers. Change each fraction to that denominator, add the top numbers, and keep the bottom the same. Then simplify.

Example: 1/2 + 1/3 → 3/6 + 2/6 = 5/6.

How do you change a mixed number into an improper fraction?

Multiply the whole number by the denominator, add the numerator, and put that total over the same denominator.

Example: 4 5/8 → (4 × 8) + 5 = 37, so the answer is 37/8.

How do you turn a fraction into a decimal?

Divide the top number by the bottom number. For 3/8, do 3 ÷ 8 = 0.375. Some fractions repeat, like 1/3 = 0.333… To get a percent, multiply the decimal by 100.

When do you flip the inequality sign?

Flip the sign only when you multiply or divide both sides by a negative number. Example: −2x > 8 becomes x < −4. Adding or subtracting never flips the sign.

How do you solve a two-step equation?

Undo the operations in reverse order. First add or subtract to move the plain number, then multiply or divide to free the variable.

Example: 3x + 2 = 23 → subtract 2 to get 3x = 21 → divide by 3 to get x = 7. Plug 7 back in to check.

How do you calculate percent change?

Subtract the old number from the new number, divide by the old number, then multiply by 100.

From 50 to 75: (75 − 50) ÷ 50 = 0.5 → 50% increase. A negative answer means a decrease.

What does mod mean in math?

Mod means the remainder after division. "17 mod 5" asks what is left over when 17 is split into groups of 5. Since 5 × 3 = 15, the answer is 2. Mod is handy for clock time and repeating patterns.

What is a unit rate?

A unit rate tells how much you get for one of something. Divide the top amount by the bottom amount. If you drive 120 miles in 2 hours, the unit rate is 120 ÷ 2 = 60 miles per hour. Unit rates help you compare prices at the store.

How do you write a number in scientific notation?

Move the decimal point until one nonzero digit is in front of it, then count the moves. That count is the power of 10.

45,000 = 4.5 × 10⁴. Small numbers use a negative power: 0.0032 = 3.2 × 10⁻³.