Math_2023_11_03_02

package homework;

/**
 * 
no  function
1   1  + 2 = 3
2   4  + 5  + 6 = 7 + 8
3   9  + 10 + 11 + 12 = 13 + 14 + 15
4   16 + 17 + 18 + 19 + 20 = 21 + 22 + 23 + 24 
5   25 + 26 + 27 + 28 + 29 + 30 = 31 + 32 + 33 + 34 + 35


44  x + (x + 1) + ... + (x + 44) = [(x + 44) + 1]  + ... + [(x + 44) + 44]




no   function
1    1    + 2                      = 3
2    4    + 5  + 6                 = 7 + 8
3    9    + 10 + 11 + 12           = 13 + 14 + 15
4    16   + 17 + 18 + 19 + 20      = 21 + 22 + 23 + 24 
5    25   + 26 + 27 + 28 + 29 + 30 = 31 + 32 + 33 + 34 + 35


44   x    + (x + 1) + ... + (x + 44)             = [(x + 44) + 1]  + ... + [(x + 44) + 44]
45   y    + (y + 1) + ... + (y + 44) + (y + 45)  = [(y + 44) + 1]  + ... + [(y + 44) + 44] + [(y + 45) + 45]


y = [(x + 44) + 44] + 1 = x + 88 + 1
y = no * no 


 *
 * @author ZengWenFeng
 * @date 2023.11.03
 * @email [email protected]
 * @mobile 13805029595
 */
public class Math_2023_11_03_02
{

	public Math_2023_11_03_02()
	{

	}

	/**
	 * 
	 * @author ZengWenFeng
	 * @date 2023.11.03
	 * @email [email protected]
	 * @mobile 13805029595
	 * @param no
	 * @return
	 */
	public static String calc(int no)
	{
		StringBuilder result = new StringBuilder();
		int first = no * no;
		result.append(first);
		
		int temp = 0;
		for (int i = 0; i < no; i++)
		{
			if (i == 0)
			{
				temp = first + 1;
			}
			else
			{
				temp = temp + 1;
			}
			
			result.append(" + " + temp);
		}
		
		result.append(" = ");
		
		for (int i = 0; i < no; i++)
		{
			temp = temp + 1;
			
			if (i == 0)
			{
				result.append(temp);
			}
			else
			{
				result.append(" + " + temp);
			}
		}
		
		return result.toString();
	}

	public static void main(String[] args)
	{
		int index = 44;
		System.out.println(calc(index));
		
		/**
		 * 
			1936 + 1937 + 1938 + 1939 + 1940 + 1941 + 1942 + 1943 + 1944 + 1945 + 
			1946 + 1947 + 1948 + 1949 + 1950 + 1951 + 1952 + 1953 + 1954 + 1955 + 
			1956 + 1957 + 1958 + 1959 + 1960 + 1961 + 1962 + 1963 + 1964 + 1965 + 
			1966 + 1967 + 1968 + 1969 + 1970 + 1971 + 1972 + 1973 + 1974 + 1975 + 
			1976 + 1977 + 1978 + 1979 + 1980 
			=
			1981 + 1982 + 1983 + 1984 + 1985 + 1986 + 1987 + 1988 + 1989 + 1990 + 
			1991 + 1992 + 1993 + 1994 + 1995 + 1996 + 1997 + 1998 + 1999 + 2000 + 
			2001 + 2002 + 2003 + 2004 + 2005 + 2006 + 2007 + 2008 + 2009 + 2010 + 
			2011 + 2012 + 2013 + 2014 + 2015 + 2016 + 2017 + 2018 + 2019 + 2020 + 
			2021 + 2022 + 2023 + 2024

		 * 
		 */
	}

}

Math_2023_11_03_02_第1张图片

2023.11.03 homework-CSDN博客

你可能感兴趣的:(java,java)