<!DOCTYPE html> <html> <head> <title>Sequence Mean Calculator</title> <style> body { font-family: Arial, sans-serif; } .result { margin-top: 20px; } .calculation { margin-bottom: 30px; border-bottom: 1px solid #ccc; padding-bottom: 20px; } .notes { margin-top: 10px; } </style> <script> let allCalculations = []; function calculateMeans() { const sequences = document.getElementById("sequences").value.trim().split('\n'); const calculation = { results: [], notes: '', sumOfMeans: 0, sumOfRemainders: 0, sumOfSequenceSums: 0, sumOfDigitsCounts: 0 }; sequences.forEach((sequence, index) => { // Remove all non-digit characters const cleanedSequence = sequence.replace(/[^0-9]/g, ''); const numbers = cleanedSequence.split('').map(Number); const sum = numbers.reduce((acc, num) => acc + num, 0); const mean = sum / numbers.length; const details = numbers.join(' + ') + " = " + sum; const formula = `${sum} / ${numbers.length} = ${mean.toFixed(3)}`; const result = { sequence: sequence, details: details, formula: formula, mean: mean, sum: sum, digitsCount: numbers.length }; calculation.results.push(result); calculation.sumOfMeans += mean; calculation.sumOfRemainders += mean - Math.floor(mean); calculation.sumOfSequenceSums += sum; calculation.sumOfDigitsCounts += numbers.length; }); allCalculations.push(calculation); displayCalculations(); } function displayCalculations() { const resultDiv = document.getElementById("result"); resultDiv.innerHTML = ""; allCalculations.forEach((calculation, calcIndex) => { let calcHTML = ` <div class="calculation"> <h2>Calculation ${calcIndex + 1}</h2> `; calculation.results.forEach((result, index) => { calcHTML += ` <div class="sequence-result"> <strong>Sequence ${index + 1}:</strong><br> ${result.sequence} -> Mean = <br> ${result.details}<br> ${result.formula}<br><br> </div> `; }); const sumOfMeans = calculation.sumOfMeans; const sumOfMeansDividedByFour = sumOfMeans / 4; const sumOfRemainders = calculation.sumOfRemainders; const sumOfSequenceSums = calculation.sumOfSequenceSums; const sumOfDigitsCounts = calculation.sumOfDigitsCounts; calcHTML += ` <div class="notes"> <label for="notes-${calcIndex}">Notes:</label><br> <textarea id="notes-${calcIndex}" rows="4" cols="50" oninput="updateNotes(${calcIndex}, this.value)">${calculation.notes}</textarea> </div> <div class="additional-results"> <h3>Additional Results</h3> <p>1. Sum of all means: ${sumOfMeans.toFixed(3)}</p> <p>2. Sum of all means / 4: ${sumOfMeansDividedByFour.toFixed(3)}</p> <p>3. Sum of remaining means: ${sumOfRemainders.toFixed(3)}</p> <p>4. Sum of all sums of sequences: ${sumOfSequenceSums.toFixed(3)}</p> <p>5. Sum of all sums of the number of digits in sequences: ${sumOfDigitsCounts.toFixed(3)}</p> </div> </div> `; resultDiv.innerHTML += calcHTML; }); } function updateNotes(calcIndex, value) { allCalculations[calcIndex].notes = value; } function resetAll() { allCalculations = []; document.getElementById("sequences").value = ""; document.getElementById("result").innerHTML = ""; } </script> </head> <body> <h1>Sequence Mean Calculator</h1> <textarea id="sequences" rows="4" cols="50" placeholder="Enter sequences, each on a new line"></textarea><br> <button onclick="calculateMeans()">Calculate Means</button> <button onclick="resetAll()">Reset All</button> <div id="result" class="result"></div> </body> </html>
Write, Run & Share HTML code online using OneCompiler's HTML online Code editor for free. It's one of the robust, feature-rich online Code editor for HTML language, running on the latest version HTML5. Getting started with the OneCompiler's HTML compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as HTML
. You can also specify the stylesheet information in styles.css
tab and scripts information in scripts.js
tab and start coding.
HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.
<!DOCTYPE html>
<html>
and ends with </html>
<h1>
to <h6>
where <h1>
is the highest important heading and <h6>
is the least important sub-heading.<p>..</p>
tag.<a>
tag.
<a href="https://onecompiler.com/html">HTML online compiler</a>
<img>
tag, where src
attribute consists of image name.<button>..</button>
tag<ul>
for unordered/bullet list and <ol>
for ordered/number list, and the list items are defined in <li>
.<a href="https://onecompiler.com/html">HTML online compiler</a>
CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.
Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.
body{
padding: 25px;
}
.title {
color: #228B22;
font-family: Candara;
}
<table>
tag.<tr>
tag<th>
tag<td>
tag<caption>
tag<script>
is the tag used to write scripts in HTML<script src="script.js"></script>