Question

(This is for matlab or similar programs to matlab) The sum of the squares of the...

(This is for matlab or similar programs to matlab)

The sum of the squares of the first ten natural numbers is,

1^2+ 2^2+...+ 10^2= 385

The square of the sum of the first ten natural numbers is,

(1 + 2 +...+ 10)^2= 55^2= 3025

Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is

3025−385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

sumOfSquares = 0;
squareOfSums = 0;
for i=1:100
    sumOfSquares = sumOfSquares + i^2;
    squareOfSums = squareOfSums + i;
end
squareOfSums = squareOfSums^2;
fprintf("%d\n",squareOfSums-sumOfSquares);

25164150

Add a comment
Know the answer?
Add Answer to:
(This is for matlab or similar programs to matlab) The sum of the squares of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (do in Java ) The sum of the squares of the first ten natural numbers is,...

    (do in Java ) The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640. Find the difference between the...

  • ANSWER USING JAVA CODE (1)The sum of the squares of the first ten natural numbers is,...

    ANSWER USING JAVA CODE (1)The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640. Find the difference between the...

  • What is the treatment sum of squares? What is the error sum of squares? What is...

    What is the treatment sum of squares? What is the error sum of squares? What is the treatment mean square? What is the block mean square?   What is the mean square error?     What is the value of the F statistic for blocks?   Can we reject the Null Hypothesis? Why? Test H0: there is no difference between treatment effects at α = .05. Block Treatment Mean Treatment Tr1 T2 Tr3 Block Mean 2 1 3 1 4 4 რ Nw NN...

  • Write C++ programs that create TEN(10) different N*N magic squares. A square matrix is the arrangement...

    Write C++ programs that create TEN(10) different N*N magic squares. A square matrix is the arrangement of the numbers 1, 2, ., N2, in which the sum of rows, columns, and diagonals are the same. The users (i.e., TAs) will specify the size of the square matrix: N. The value N must be an odd number between 3 and 15. Example Run For example, you program is expected to run as the following way. NOTE: We only list 5 magic...

  • e. Set up the ANOVA table for this problem. Round all Sum of Squares to nearest...

    e. Set up the ANOVA table for this problem. Round all Sum of Squares to nearest whole numbers. Round all Mean Squares to one decimal places. Round F to two decimal places. Source of Variation Sum of Squares Degrees of Freedom Mean Square F Treatments Error Total f. At the α-.05 level of significance, test whether the means for the three treatments are equal The p-value is less than.01 What is your conclusion? Select The following data are from a...

  • IN MATLAB RECURSIVE FUNCTION 1. Sum of Factorials. The Recursive Function: A series that sums up...

    IN MATLAB RECURSIVE FUNCTION 1. Sum of Factorials. The Recursive Function: A series that sums up the factorial of the natural numbers from 1 to N can be expressed as The recursive algorithm: N-1 N-2 N-3 Write independent matlab code to solve the above problem with the following methods: 1. 2. 3. A monolithic program (with no functions) A standard (non-recursive) user defined function (an a program to call it) A recursive function (an a program to call it) Test...

  • Rewrite the quadratic portion of the algebraic expression as the sum or difference of two squares...

    Rewrite the quadratic portion of the algebraic expression as the sum or difference of two squares by completing the square. x2 + 6x + 10 Need Help? Ras 10 1.4 062 Use the di ant to determine the number of real solutions of the quadratic equation 7x2-3x +1 0 O Type here to search

  • Solve using Matlab Write a simple loop to list the squares of the first 10 integers....

    Solve using Matlab Write a simple loop to list the squares of the first 10 integers. Using a simple "while" loop, write a script to sum the series 1 + 2 + 3 + ... such that the sum is as large as possible without exceeding 100. The program should display how many terms are used in the sum. Write a script that takes as input an integer n and creates the n*n matrix A with (ij)th component given by...

  • Magic Squares; Java code

    Magic squares. An n × n matrix that is filled with the numbers 1, 2, 3, ..., n2 is a magic square if the sum ofthe elements in each row, in each column, and in the two diagonals is the same value. For example,16 3 2 135 10 11 89 6 7 124 15 14 1Write a program that reads in n2 values from the keyboard and tests whether they form a magic squarewhen arranged as a square matrix. You...

  • C++ This week, you are to create two separate programs, first using a simple array and...

    C++ This week, you are to create two separate programs, first using a simple array and the second using a 2D-array (matrix). [Part 1] Write a program that accepts exactly ten (10) integer numbers from the user and stores them in an array. In a separate for-loop, the program then goes through the elements in the array to print back: (i) The sum of the 10 numbers, (ii) the minimum value from the 10 numbers, and (iii) the maximum value...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT