There is a fractional sequence of 2/1 + 3/2 + 5/3 + 8/5 + 13/8 +... Find the sum of the first 20 items of the series.Program:
# Include
Output result: 32.660261 Press any key to continue
C language: There is a score sequence: 2/1 + 3/2 + 5/3 + 8/5 + 13/8 +... Find the sum of the first 20 items in this seriesProgram:
# Include
Output result: 32.660261 Press any key to continue
Server OSWindowsLinuxUnix:system (Bell Lab, Aix Solaris Hp_ux), BSD (NetBSD OpenBSD FreeBSD)Linux origins1984 Richard Stallman launched the GNU program, developed UNIX-based free software and tools to represent GCC VICreate GPL Public License1991 Linux Torvalds releases Linux and joins GNULinux Official website: www.kernel.orgThe Linux system is a combination of the kernel and GNU softwareCommon versions of LinuxSlackware:suse Enterprise Server, openSUSE DesktopDebian:ununtu,mintRedhat:redhat En
Method Oneimport functoolssum = 0for i in range(1,21):sum = sum + functools.reduce(lambda x,y: x*y, range(1, i+1))print(sum)Lambda x,y:x*y means: There is a function that accepts X, y two parameters to do multiplication.import functoolsMethod Twodef f(n):if n == 1:return 1else:return functools.reduce(lambda x,y: x*y, range(1, n+1)) + f(n-1)print(f(20))Method Threedef plus(n):if n == 1:return 1else:return reduce(lambda x,y: x*y, range(1,n+1)) + plus(n-
Starting 3 threads, thread 1 printing 1 to 5, thread 2 printing 5 to 10, thread 3 printing 11 to 15, then thread 1 printing 16 to 20, and so on ...
Print until 30 public class Mainthread {private static int num;//current record number private static final int threadnum =3;//open Task thread count private static final int loopnum = number of 2;//threadnum thr
/***//**
* Fractionserial. Java
* There is a fractional sequence: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13...
* Calculate the sum of the first 20 items of the series.
* @ Author Deng Chao (codingmouse)
* @ Version 0.2
* Development/test environment: jdk1.6 + eclipse SDK 3.3.2
*/
Public class fractionserial ...{
Public static void main (string [] ARGs )...{
/**//*
* Not
# Include
}/* The numerator behind the score is equal to the numerator plus the denominator of the previous score, and the denominator of the subsequent score is equal to the numerator with the previous score */
There is a fractional sequence: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13... find the sum of the first 20 items of this series
This article is from my translation of the Infoq Chinese station, the original address is: Http://www.infoq.com/cn/news/2015/06/Building-Distributed-SystemsThis June 12, the jetty project released the 9.3 version of the flagship open source embedded application server, which was also the 20 anniversary of the project. The main features of this release include increased support for the HTTP/2 server (with th
This article is from my translation of the Infoq Chinese station, the original address is: Http://www.infoq.com/cn/news/2015/06/Building-Distributed-SystemsJune 12 this year. The jetty project unveiled the 9.3 version of the flagship open source embedded application server, which is also the 20-year anniversary of the project. The main features of this announcement include the addition of support for HTTP/2
After a fraction of the numerator = numerator of the previous fraction + denominator, the denominator of the next fraction = the numerator of the previous fraction, the cycle is 20 times the result. Note that the numerator is a and the denominator is B, although a = a + B,But at this point A has become a+b, so to re-assign the value of the time, it is (a+b)-B to be equal to the original denominator B, so re-assignment should be written as a-aMethod On
Write a program and use the while statement to calculate 1 + 1/2! + 1/3 !...... + 1/20 !, And output the computing results in the control of Taishan. Requirement 1 + 1/2! + 1/3 !...... + 1/20 !, In fact, it is to calculate 1 + 1*1/2 + 1*1/
If the values of the struct field are in the order of 1, 2, 3, 11, 12, 20, and 21, if we want to sort this field, it is generally written in this way.
SQL statement:
Select * From xs_jbxx order by jyjxsbmBut the results may not be satisfactory: 1, 11, 12, 2, 20, 21, 3, 4
The results we want are: 1,
IOS Study Notes 20-map (2) MapKit framework1. Introduction to map development
Since iOS6.0, map data is no longer driven by Google, but switched to its own map. Of course, its data in China isAMAPProvided.There are three main ways to develop maps in iOS:
MapKitThe framework is used for map development. This method can be used to precisely control maps and call the map application provided by Apple. It is ma
Drink soda, 1 bottles of soda 1 yuan, 2 empty bottles can change a bottle of soda, to 20 yuan, how much soda can. Programmatic implementation.
The whole idea : a recursive way to achieve, each recursive means that this time can buy soda bottle number (M). First of all, to determine whether M is able to fully redeem (m even), in two cases:
If can (M is even), again m/2
factorial of 1-20 to the list, sum with the SUM function." Center ("*") ) Range (1,21): list.append (Recursion (i) # appends the factorial value generated by the calling recursive function to the list print (sum (list)) #列表求和Full source code and results:def recursion (n): # ' define recursive function for factorial function ' if n==1: return 1 else: return n*recursion (n-1) list=[] #定义一个空的列表, append the factorial value gene
Write a program using C language to solve there is a fractional sequence: 2/1,3/2,5/3,8/5,13/8,21/13 ... find the first 20 items of this sequencevoid Test () {///idea: rule-based starting from 3/2 the denominator of the next number is the numerator of the previous number, the next number of numerator is the numerator of the previous number of the denominator and
Weekly Report: From January 1, October 29-20, 2018 to January 1, November 2
Monday 10.29
Debugging and testing of client logon.
The addition of subject database fields solves the problem of deleting the question library.
FTP configuration, permission configuration research, data query, and experiment.
Communicate with Xia to clarify the development tasks of this week.
Tuesday 10.30
The Research o
PackageNothh; Public classMMM { Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//compared to the sum of factorial, the inverse of factorial and the need to use a float or double. floatx = 0; floaty = 0; intz = 20; while(z>0) {x=Z; for(intj = z-1; J > 0; j--) {x= J *x; } z--; //On the basis of the sum of the factorial, the reciprocal value of x is assigned. x = 1/x; Y= x+y; } System.out.println (y)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.