java – Sum of a sequence by using for and while loop

package com.company;
import java.util.Scanner;

public class Main {

public static void main(String() args) {
    Scanner scanner = new Scanner(System.in);
    System.out.println("Last Number ");
    int inputedNumber = Integer.valueOf(scanner.nextInt());
    int result = 0;
    int outcome = 0;
    for(int i = 0; i < inputedNumber; i++) {
        result += ;
    }
    /*/*while (outcome <= inputedNumber) {
        result += inputedNumber;
        outcome++;
    }*/
    System.out.println(result);
}

}

I have a problem to understand what is wrong here, because I would like to solve the task , originally it should be (Implement a program, which calculates the sum 1+2+3+…+n where n is given as user input.) but it gives me another answer, please , pin out for me in a both way , to understand what I went wrong , because everything so far make sense for me , but code doesn’t work as it should to be

Sum and Prod problem

How can I find teh result of:

$sum_{i=1}^{n}prod_{j=1}^{2} ij$

I know that $prod_{j=1}^{2} ij = 2i^2$, so I should simply do the summatory as $sum_{i=1}^n2i^2$?

Sum values across multiple Sheets IDs automatically by creating a formula?

I used this question to have all google sheets IDs in a folder
Getting all files’ file-id from a folder in Google Drive

I would like to make a formula to sum values in table across all these sheets IDs (note, the table is present in all sheets with same cell range)..

Instead of copying and pasting the sheets Ids manually every time, I would like to make formula with variables that represents sheets ID so that every time i just past the sheets ID and the variables are assigned for each sheets>>>

Some thing in my mind like this
a=18Q62TvfWkKatZQDM0dzZUU1g6CzEG-QfWPc0tsZb3cU

b= 1H6VCXzfcXKfsAEI7ZjU66NUWtE2TdPQUKTUKYS2gN3I

c=,,,

And so on,,, while the formula is fixed

reference request – Specific criterion for the sum of two closed sets to be closed

Let $Y$ and $Z$ be two closed subspaces of a Banach space $X$ with $Ycap Z={0}$.

I know that $Y+Z$ is a closed subspace of $X$ $iff exists α>0:quad ∥y∥≤α∥y+z∥forall y∈Y,forall z∈Z$.

However, reading this question A criterion for the sum of two closed sets to be closed ? commenter posted that: the standard equivalence to the sum being closed is that the unit spheres of $Y$ and $Z$ are a positive distance apart i.e. $∃r>0quad ∥y−z∥≥rquad ∀y∈Y,∀z∈Zquad s.t.quad ∥y∥=∥z∥=1$.

Could anybody provide me with a proof or rather a reference to where I can see the proof of this equivalence?

algorithms – Finding a series of numbers that maximise $ sum f_i(x_i) $

This problem can be solved using dynamic programming.

For $i in {1, dots, m}$ define $F_i(x)$ as the maximum value $sum_{j=1}^i f_j(x_j)$ attainable for a suitable choice of $x_1, dots, x_i$ such that $x_1 + dots + x_i le x$. That is:
$$F_i(x) = max_{substack{x_1, dots, x_i in {0, dots, m} \ x_1 + dots + x_i le x}} sum_{j=1}^i f_j(x_j).
$$

As a special case let $F_0(x) = 0$. You can then write $F_i(x)$, with $i ge 1$, as follows:
$$
F_i(x) = max_{y in {0, dots, x}} big{ f_i(y) + F_{i-1}(x-y) big}.
$$

Computing all values $F_i(0), dots, F_i(m)$ in increasing order of $i$ using the above identity immediately yields an algorithm with a running time of $O(m^3)$ to compute the optimal value of $sum_{i=1}^m f_i(x_i) = F_m(m)$.

Using standard techniques you can then also find an optimal assignment to $x_1, dots, x_m$.

Sum over a formula in google sheets

I have a google sheet and I need to add a lot of stuff like

(ABS(A1)+A1)/A1+ (ABS(A2)+A2)/A2+…+ (ABS(A10)+A10)/A10

but I don’t want to write out the sum each time for each term A1,A2,A3,…, A10

Is there a way to write the sum more concise? like

SUM( (|x| + x)/x : for x from A1 to A10)

^I know that’s not correct but that is what I want

sum of squares of the coefficients of a monic polynomial

Consider the monic polynomial $$f: = X^n + a_1 X^{n-1} + cdots + a_n$$ over $mathbb Z$. Let $p_i$ be the $i$_th power sum ($1 le i le n$) of the roots of $f$ (in some extension of $mathbb Z$). What is the formula for ${a_1}^2 + {a_2}^2 + cdots + {a_n}^2$ in terms of the $p_i$ ($1 le i le n$).

Sum Last 12 Columns In Google Sheets

I’m trying to track my recent 12 months spend on an ongoing basis. Each month a new column is added for the new month, but I want Column B to show the sum of the most recent 12 months.

The formula that I’ve tried in cell B2 is (not working):

=SUM(QUERY(SORT(C2:AZ2, Column(C2:AZ2)*ISNUMBER(C2:AZ2), 0), "select * limit 12"))

oracle – How can I use COUNT in the same query with SUM()?

Ok, I have three tables: theater, spectacles and tickets. A theater has one or more spectacles and for a spectacle were sold one or more tickets* So, id_theater is foreign key in TABLE SPECTACLES and id_spectacle is foreign key in TABLE TICKETS. In table TICKETS, I have ticket_price and id_ticket and with count(id_ticket) I calculate the number of tickets sold for spectacles. And each theater has one or more spectacles. The value for spectacles is calculated as: count(tickets.id_ticket) * tickets.ticket_price. After I calculate the value for spectacles, I need to gather the value of spectacles to find the each value of theater and for this I use SUM().

I need to write a query where I need to calculate the total value obtained by each theater and to be sort by value. For this I need to use the SUM() function. I tried so many different options, but I have different errors. When I tried to run this, this error appeared :

SQL Error: ORA-00937: not a single-group group function
SELECT 
     theater.id_theater, 
     SUM(count(tickets.id_ticket) * tickets.id_ticket) total_theater
FROM spectacles, theater
GROUP BY theater.id_theater
ORDER BY total_theater DESC;

For this problem I must use SUM, but I really don’t know what do to at this point and would appreciate any help.

javascript – Advent Of Code 2020, day 1, find desired sum and multiply the addends

you can find the challenge here for more details, but the subject says it all;

Check a provided list of entries for 2 numbers which sum to 2020, return the product of those addends.

I waited until the event was over to keep things fair.

/*This will search for 2 numbers in the `list that sum to `target` 
  Assumption;
  * We only get integers in a string that are new-line separated
  * The sum is there, so we dont stop searching even if it doesnt make sense
*/
function findTargetSum(listAsString, target){
  const list = entries.split('n').map(s => s*1);
  const set = new Set(list);
  for (const i of set) {
     if(set.has(target - i)){
       return i * (target - i);
     }
  }
}

const entries = `1780
1693
1830
1756
1858
1868
1968
1809
1996
1962
1800
1974
1805
1795
170
1684
1659
1713
1848
1749
1717
1734
956
1782
1834
1785
1786
1994
1652
1669
1812
1954
1984
1665
1987
1562
2004
2010
1551
961
1854
2005
1883
1965
475
1776
1791
262
1912
1227
1486
1989
1857
825
1683
1991
1875
1982
1654
1767
1673
1973
1886
1731
1745
1770
1995
1721
1662
1679
1783
1999
1889
1746
1902
2003
1698
1794
1798
1951
1953
2007
1899
1658
1705
62
1819
1708
1666
2006
1763
1732
1613
1841
1747
1489
1845
2008
1885
2002
1735
1656
1771
1950
1704
1737
1748
1759
1802
2000
1955
1738
1761
1765
1853
1900
1709
1979
1911
1775
1813
1949
1966
1774
1977
1757
1992
2009
1956
1840
1988
1985
1993
1718
1976
1078
1997
1897
1792
1790
1801
1871
1727
1700
1485
942
1686
1859
1676
802
1952
1998
1961
1844
1808
1703
1980
1766
1963
1849
1670
1716
1957
1660
1816
1762
1829
526
359
2001
1874
1778
1873
1511
1810
1699
1970
1690
1978
1892
1691
1781
1777
1975
1967
1694
1969
1959
1910
1826
1672
1655
1839
1986
1872
1983
1981
1972
1772
1760`;

console.log(findTargetSum(entries, 2020));