Guide :

# write an algorithm that finds the sum of all integers in a list

describe what the fpllowing algorithm do or does not do?

## Research, Knowledge and Information :

### 4.3. Calculating the Sum of a List of Numbers — Problem ...

Calculating the Sum of a List of Numbers ... This is the reason that we call the listsum algorithm recursive. A recursive function is a function that calls itself.

### Algorithms, Integers - Northwestern University

Algorithms, Integers ... F1 = 1 and each subsequent term is the sum of the two previous ... minimum time needed to execute the algorithm among all inputs of a given ...

### How to write an algorithm to check if the sum of any two ...

How can I write an algorithm to check if the sum of any two numbers in an array/list ... I assume that you have all positive integers. ... Console.Write ("i =" + i ...

### Algorithm Homework and Test Problems - SBU

Algorithm Homework and Test Problems ... Partition the integers n 1 into groups such that all the integers in a group have ... Algorithm A takes n2 days to solve a ...

### algorithm - Write a program to find 100 largest numbers out ...

I recently attended an interview where I was asked "write a program to find 100 largest ... algorithm - The algorithm finds ... sum to X in an array of integers of ...

### Simple algorithms - Department of Math/CS

We must compute the sum of all the values store in the ... , the algorithm finds the correct ... When you write real world computer applications that ...

### How to write an algorithm to find the sum of the first 50 ...

How do you write an algorithm to find the sum of the first 50 numbers? ... Is it positive integers? ... How do you write an algorithm that adds numbers?

### What is the most efficient algorithm to find out if an ...

What is the most efficient algorithm to ... How do I find the sum of all the integers between 10 and 200 divisible by 7 and then write the sigma notation for the sum ...

### Chapter 3

hence so is the sum. ... An algorithm that finds the average of n numbers by adding them and ... List all positive integers less than 30 that are relatively prime ...

### Assignments_Week_5_PE_MATH-150 - Course Hero

Devise an algorithm that finds the sum of all the integers in a list ... Describe an algorithm that will count the number of 1s ... Assignments_Week_5_PE_MATH ...

## Suggested Questions And Answer :

### write an algorithm that finds the sum of all integers in a list

me dun it alredee www.munee.info/jp32prt1.htm

### how to factor integers

1. basik idea is yukan divide 1 integer intu other integer if result is exact...if leftover=0, then the bottom number is a fakter av the top number 2. tu fakter a number is: tri all possabel smaller numbers tu find all that R fakters    divide bi 2, 3, 4...up tu (top number)/2 3. prime number...no fakters (yu dont divide bi 1, start with 2) 4. prime fakters: wen yu divide, oenlee divide bi prime numbers "gratest fakter"=biggest number in yer list av fakters 5. kommon fakters...du this tu 2 numbers & then thro awae NE number that is NOT a fakter av both top numbers

### 40 sum from 3 by 3 magic squares

Label the squares A to I: A B C D E F G H I  If each row and column is to sum to 40 then the three rows added together must sum to 120: (A+B+C)+(D+E+F)+(G+H+I)=40+40+40=120, which is the sum of all numbers used. The consecutive numbers 1 to 9 add up to 45, which is 75 short of 120. If we use the numbers 2, 4, 6, ..., 18 the sum would be 90, 30 short of 120. If we bias the numbers by starting from a different number, we can make up the difference. Let the numbers be in order, nx+a where x is between 1 and 9, and a is a bias (a number to be added to each nx) and n is to be an integer, then the sum of all the numbers is n+a+2n+a+3n+a+...+9n+a=45n+9a=120. That is, 5n+a=120/9=40/3. So one solution is n=2 and a=40/3-10=10/3. For numbers 1 to 9, a magic square is typically: 8 1 6 3 5 7 4 9 2 We use the conversion nx+a: 1→16/3, 2→22/3, 3→28/3, 4→34/3, 5→40/3, 6→46/3, 7→52/3, 8→58/3, 9→64/3: 58/3 16/3 46/3 28/3 40/3 52/3 34/3 64/3 22/3  In this square the fractions sum to 40. If we write a=40/3-5n=5(8-3n)/3 or n=(40/3-a)/5=(40-3a)/15 or 8/3-a/5, we can find other values for a and n. Then we can convert the numbers 1 to 9 using the formula x→nx+a. GENERAL 3 x 3 MAGIC SQUARE SOLUTIONS Represent square using letters: A B C D E F G H I A+B+C=S=D+E+F=G+H+I; A+B+C+D+E+F+G+H+I=3S, where S is the common sum. A+E+I=B+E+H=C+E+G=D+E+F=S (A+B+C+D+E+F+G+H+I)+3E=4S; 3S+3E=4S, E=S/3. A+E+I=S, I=S-E-A, I=2S/3-A. H=S-E-B, H=2S/3-B. C=S-(A+B). G=2S/3-C=2S/3-S+(A+B), G=A+B-S/3. D+G=B+C=B+S-(A+B)=S-A; D=S-A-G=S-A-A-B+S/3, D=4S/3-(2A+B). F=2S/3-D=2S/3-4S/3+2A+B, F=2A+B-2S/3. Completed square:           A            B             S-(A+B) 4S/3-(2A+B)    S/3    2A+B-2S/3    A+B-S/3    2S/3-B      2S/3-A So A and B are arbitrary; S must be a multiple of 3 if square is to be whole numbers only. EXAMPLE: A=1, B=5, S=18:   1  5  12 17  6  -5   0  7  11 Since squares can be rotated and reflected, A and B could have been 1 and 17, 12 and 5, 11 and -5, etc., to produce the same square effectively.

### 0,2,4,4,6,8,9,11,13,15 what are the five numbers?

Call the 5 numbers A, B, C, D and E. We assume these to be integers, since there's no indication otherwise. The sums are A+B, A+C, A+D, A+E, B+C, B+D, B+E, C+D, C+E, D+E. Let's look at the sum zero. To get the sum of two number to be zero, they're either both zero or one is the negative of the other. Let's assume there are no negative numbers, so two numbers must be zero. So A=B=0. 6 of the remaining numbers involve A or B, so the sums would be C, D, E, C, D, E, i.e., three pairs of identical sums. But we only have one pair, so the assumption of no negative numbers is wrong. Therefore, there is at least one negative number in the set and A=-B. The sums involving A and B we can write C+A, C-A, D+A, D-A, E+A, E-A. Do we have 6 sums that could fit these? Yes, we do. The 6 sums would enable us to find A, since, for example, (C+A)-(C-A)=2A=(D+A)-(D-A)=(E+A)-(E-A). The difference between the pairs of sums is 2 for each pair, implying that A=1 and therefore B=-1. The first two pairs are 2 and 4 and 4 and 6, because we have two 4's. If we add the sums in each pair we get 6 and 10. These are respectively 2C and 2D, so C=3 and D=5, making C+D=8, another of the sums. We're left with sums 9, 11, 13, 15, and we haven't found E yet. We need sums of E with the other discovered numbers, E+1, E-1, E+3, E+5 and we have four remaining sums to fit these if possible. The lowest number is 9 which must correspond to E-1. So E=10 and the other sums become 11, 13 and 15, which matches the three remaining sums. So the answer is: the numbers are -1, 1, 3, 5, 10.

### use the integers 0, -2, -3, -4, -5, -6, -7, -8, and -10 to fill in a 3x3 magic square

First, find out what the sum is. Consider 3 rows of 3 numbers: each row has sum S. The rows contain all the numbers, so since the sum of the numbers is -45, 3S=-45 and S=-15. Take each number in turn and work out what other numbers can go with it to make -15: 0: (-10,-5),(-8,-7) -2: (-10,-3),(-8,-5),(-7,-6) -3: (-10,-2),(-8,-4),(-7,-5) -4: (-9,-2),(-8,-3),(-6,-5) -5: (-10,0),(-8,-2),(-7,-3),(-6,-4) -6: (-7,-2),(-5,-4) -7: (-8,0),(-6,-2),(-5,-3) -8: (-7,0),(-5,-2),(-4,-3) -10: (-5,0),(-3,-2) Now, consider the square: C1 C2 C3 C4 C5 C6 C7 C8 C9 Each cell participates in various sums. C1, for example, is in the first row and column and on a diagonal, so it is involved in 3 sums. C3, C7 and C9 are also similarly involved. Here's a complete list: C2,C4,C6,C8: 2 sums C1,C3,C7,C9: 3 sums C5: 4 sums Now we match the number of sums with the numbers that can be involved in at least the same number of sums. C5=-5. 2 sums: {C2 C4 C6 C8}={0 -6 -10} (exact) < {-2 -3 -4 -7 -8} (3 sums) 3 sums: {C1 C3 C7 C9}={-2 -3 -4 -7 -8}, one of these can be used to satisfy 2 sums, leaving 4 to match the cells. So {C1 C3 C7 C9}={-2 -3 -4 -7)|{-2 -3 -4 -8}|{-2 -3 -7 -8}|-2 -4 -7 -8}|{-3 -4 -7 -8} and {C2 C4 C6 C8}={0 -6 -8 -10}|{0 -6 -7 -10}|{0 -4 -6 -10}|{0 -3 -6 -10}|{0 -2 -6 -10} Because of symmetry we can assign 0 to C2. So C8=-10: C1 0 C3 C4 -5 C6 C7 -10 C9 C7+C9=-5, which means only -2 and -3. Because of symmetry we can assign either number to C7: C1 0 C3 C4 -5 C6 -2 -10 -3 C1-8=-15 so C1=-7; C3-7=-15, so C3=-8: -7 0 -8 C4 -5 C6 -2 -10 -3 C4=-6 and C6=-4: -7 0 -8 -6 -5 -4 -2 -10 -3

### Answers to grade 6 unit 2: Operating with Postive Rational Numbers

???????????? "hole numbers" ???????? aent no such anamal . . . thats a long list av thangs tu du & leev yu a lotta wiggel room . . . 1: 2 INTEGERS < 100 & find kommon fakters: how bout 20 & 50 ????? . . . kommon fakters=2, 5, 10 . . . . biggest kommon fakter=10

### Find the sum of the multiples of 5 or 13 under 968

????????????????? "natural numbers" ??????????? me ges yu meen INTEGER me thank yu want 5+10+15+20+...965 sum=93,605 this be arithmatik sequens: start=5, step size=3, n=193, last=965 averaej=(start+end)/2=(965+5)/2=970/2=485 sum=n*averaej=193*485 ###### if start with 13, step size=13...get n=74, averaej=487.5, sum=36,075

### Pete challenges his friend Jill to find two consecutive odd integers that have the following relationship.

Two consecutive odd integers can be represented by 2x-1 and 2x+1. Their product is 4x^2-1 and their sum is 4x. So, 4x^2-1=3(4x+6)=12x+18. This is the quadratic: 4x^2-12x-19=0. This has no rational solutions. Or, reading the question slightly differently: 4x^2-1=12x+6, so 4x^2-12x-7=0. In the second case, we can factorise: (2x-7)(2x+1)=0, so x=3.5 or -0.5. The two integers are: 6 and 8, or -2 and 0. None of these are odd, so it isn't possible to find two consecutive odd integers. Why did I think there were two interpretations of the question? "3 times the sum of the integers plus 6" is ambiguous:  is it 3(sum+6) or 3*sum+6? Judging by the result, it was the latter.

### magic square 16 boxes each box has to give a number up to16 but when added any 4 boxes equal 34

The magic square consists of 4X4 boxes. We don't yet know whether all the numbers from 1 to 16 are there. Each row adds up to 34, so since there are 4 rows the sum of the numbers must be 4*34=136. When we add the numbers from 1 to 16 we get 136, so we now know that the square consists of all the numbers between 1 and 16. We can arrange the numbers 1 to 16 into four groups of four such that within the group there are 2 pairs of numbers {x y 17-x 17-y}. These add up to 34. We need to find 8 numbers represented by A, B, ..., H, so that all the rows, columns and two diagonals add up to 34. A+B+17-A+17-B=34, C+D+17-C+17-D=34, ... (rows) A+C+17-A+17-C=34, ... (columns) Now there's a problem, because the complement of A, for example, appears in the first row and the first column, which would imply duplication and mean that we would not be able to use up all the numbers between 1 and 16. To avoid this problem we need to consider other ways of making up the sum 34 in the columns. Let's use an example. The complement of 1 is 16 anewd its accompanying pair in the row is 2+15; but if we have the sum 1+14 we need another pair that adds up to 19 so that the sum 34 is preserved. We would perhaps need 3+16. We can't use 16 and 15 because they're being used in a row, and we can't use 14, because it's being used in a column, so we would have to use 6+13 as the next available pair. So the row pairs would be 1+16 and 2+15; the column pairs 1+14 and 6+13; and the diagonal pairs 1+12 and 10+11. Note that we've used up 10 of the 16 numbers so far. This type of logic applies to every box, apart from the middle two boxes of each side of the square (these are part of a row and column only), because they appear in a row, a column and diagonal. There are only 10 equations but 16 numbers. In the following sets, in which each of the 16 boxes is represented by a letter of the alphabet between A and P, the sum of the members of each set is 34: {A B C D} {A E I M} {A F K P} {B F J N} {C G K O} {D H L P} {D G J M} {E F G H} {I J K L} {M N O P} The sums of the numbers in the following sets in rows satisfy the magic square requirement of equalling 34. This is a list of all possibilities. However, there are also 24 ways of arranging the numbers in order. We've also seen that we need 10 out of the 16 numbers to satisfy the 34 requirement for numbers that are part of a row, column and diagonal; but the remaining numbers (the central pair of numbers on each side of the square) only use 7 out of 16. The next problem is to find out how to combine the arrangements. The vertical line divides pairs of numbers that could replace the second pair of the set. So 1 16 paired with 2 15 can also be paired with 3 14, 4 13, etc. The number of alternative pairs decreases as we move down the list. 17 X 17: 1 16 2 15 | 3 14 | 4 13 | 5 12 | 6 11 | 7 10 | 8 9 2 15 3 14 | 1 16 | 4 13 | 5 12 | 6 11 | 7 10 | 8 9 3 14 4 13 | 1 16 | 2 15 | 5 12 | 6 11 | 7 10 | 8 9 4 13 5 12 | 1 16 | 2 15 | 3 14 | 6 11 | 7 10 | 8 9 5 12 6 11 | 1 16 | 2 15 | 3 14 | 4 13 | 7 10 | 8 9 6 11 7 10 | 1 16 | 2 15 | 3 14 | 4 13 | 5 12 | 8 9 7 10 8 9 | 1 16 | 2 15 | 3 14 | 4 13 | 5 12 | 6 11 16 X 18: 1 15 2 16 | 4 14 | 5 13 | 6 12 | 7 11 | 8 10 2 14 3 15 | 5 13 | 6 12 | 7 11 | 8 10 3 13 4 14 | 2 16 | 6 12 | 7 11 | 8 10 4 12 5 13 | 2 16 | 3 15 | 7 11 | 8 10 5 11 6 12 | 2 16 | 3 15 | 4 14 | 8 10 6 10 7 11 | 2 16 | 3 15 | 4 14 | 5 13 7 9 8 10 | 2 16 | 3 15 | 4 14 | 5 13 | 6 12 15 X 19: 1 14 3 16 | 4 15 | 6 13 | 7 12 | 8 11 2 13 4 15 | 3 16 | 5 14 | 7 12 | 8 11 3 12 5 14 | 4 15 | 6 13 | 8 11 4 11 6 13 | 3 16 | 5 14 | 7 12 5 10 7 12 | 3 16 | 4 15 | 6 13 | 8 11 6 9 8 11 | 3 16 | 4 15 | 5 14 | 7 12  7 8 9 10 | 3 16 | 4 15 | 5 14 | 6 13 14 X 20: 1 13 4 16 | 5 15 | 6 14 | 8 12 | 9 11 2 12 5 15 | 4 16 | 6 14 | 7 13 | 9 11 3 11 6 14 | 4 16 | 5 15 | 7 13 | 8 12 4 10 7 13 | 5 15 | 6 14 | 8 12 | 9 11 5 9 8 12 | 4 16 | 6 14 | 7 13 | 9 11 6 8 9 11 | 4 16 | 5 15 | 7 13 13 X 21: 1 12 5 16 | 6 15 | 7 14 | 8 13 | 10 11 2 11 6 15 | 5 16 | 7 14 | 8 13 | 9 12 3 10 7 14 | 5 16 | 6 15 | 8 13 | 9 12 4 9 8 13 | 5 16 | 6 15 | 7 14 | 10 11 5 8 9 12 | 6 15 | 7 14 | 10 11 6 7 10 11 | 5 16 | 8 13 | 9 12 12 X 22: 1 11 6 16 | 7 15 | 8 14 | 9 13 | 10 12 2 10 7 15 | 6 16 | 8 14 | 9 13 | 10 12 3 9 8 14 | 6 16  4 8 9 13 | 6 16 | 7 15  5 7 10 12 | 6 16 11 X 23: 1 10 7 16 | 8 15 | 9 14 2 9 8 15 | 7 16  3 8 9 14 | 7 16  10 X 24: 1 9 8 16 To give an example of how the list could be used, let's take row 3 in 17 X 17 {3 14 4 13}. If 3 is the number in the row column and diagonal, then we need to inspect the list to find another row in a different group containing 3 that doesn't duplicate any other numbers. So we move on to 15 X 19 and we find {3 12 8 11} and another row in 13 X 21 with {3 10 5 16}. So we've used the numbers 3, 4, 5, 8, 10, 11, 12, 13, 14, 16. That leaves 1, 2, 6, 7, 9, 15. In fact, one answer is: 07 12 01 14 (see 15x19) 02 13 08 11 16 03 10 05 09 06 15 04