# Commits

committed 67aaa1f

• Participants
• Parent commits f9e1fd6
• Branches dev

# File src/projectEuler/1.go

`+//Copyright (C) 2012 Eric Chen(G+ page:HencriceFOSS, gmail:hencrice+FOSS+introtoalgorithm3ed@gmail.com)`
`+//`
`+//This file is a part of introtoalgorithm3ed.`
`+//`
`+//introtoalgorithm3ed is a free software; you can redistribute it and/or modify it under the terms of the GNU General `
`+//Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) `
`+//any later version.`
`+//`
`+//This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the `
`+//implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public `
`+//License for more details.`
`+//`
`+//You should have received a copy of the GNU General Public License along with this source file; if not, write to the `
`+//Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA`
`+`
`+//Task: Find the number of inversions in the file given. `
`+//The file contains all the 100,000 integers between 1 and 100,000 (including both) in some random order(no integer is repeated).`
`+package main`
`+`
`+import (`
`+	"fmt"`
`+)`
`+`
`+func main() {`
`+	/*`
`+	If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these `
`+	multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.`
`+	*/`
`+	sum3:=(3+(1000/3)*3)*(1000/3)/2.0`
`+	sum5:=(5+(1000/5-1)*5)*(1000/5-1)/2.0`
`+	sum15:=(15+(1000/15)*15)*(1000/15)/2.0`
`+	fmt.Printf("Result:%f\n",sum3+sum5-sum15)`
`+}`

# File src/projectEuler/2.go

`+//Copyright (C) 2012 Eric Chen(G+ page:HencriceFOSS, gmail:hencrice+FOSS+introtoalgorithm3ed@gmail.com)`
`+//`
`+//This file is a part of introtoalgorithm3ed.`
`+//`
`+//introtoalgorithm3ed is a free software; you can redistribute it and/or modify it under the terms of the GNU General `
`+//Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) `
`+//any later version.`
`+//`
`+//This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the `
`+//implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public `
`+//License for more details.`
`+//`
`+//You should have received a copy of the GNU General Public License along with this source file; if not, write to the `
`+//Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA`
`+`
`+//Task: Find the number of inversions in the file given. `
`+//The file contains all the 100,000 integers between 1 and 100,000 (including both) in some random order(no integer is repeated).`
`+package main`
`+`
`+import (`
`+	"fmt"`
`+)`
`+`
`+func main() {`
`+	/*`
`+	Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, `
`+	the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...`
`+	By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the `
`+	even-valued terms.`
`+	*/`
`+	/*I find that Fibonnacci sequence has a pattern beginning from 3, namely, (odd,odd,even),(odd,odd,even)......`
`+	  3, 5, 8, 13, 21, 34, 55, 89, ...`
`+	  o, o, e, o , o,  e,  o  ,o, e`
`+	*/`
`+	var a,b,temp,evenSum,ooeCount uint32=1,2,0,2,0`
`+	for i := 0; i < 50; i++ {`
`+		temp=a+b`
`+		a=b`
`+		b=temp`
`+		ooeCount++`
`+		if temp>4*1000000{`
`+			fmt.Printf("Bigger than 4 million: %d, %d\n",temp,temp%2)`
`+			break`
`+		} else {`
`+			if ooeCount%3==0{`
`+				evenSum+=temp`
`+				fmt.Printf("evenSome increase to:%d\n",evenSum)`
`+			}`
`+		}`
`+		fmt.Printf("%d, %d\n",temp,temp%2)`
`+	}`
`+	fmt.Printf("Final evenSum=%d\n",evenSum)`
`+}`

# File src/projectEuler/3.go

`+//Copyright (C) 2012 Eric Chen(G+ page:HencriceFOSS, gmail:hencrice+FOSS+introtoalgorithm3ed@gmail.com)`
`+//`
`+//This file is a part of introtoalgorithm3ed.`
`+//`
`+//introtoalgorithm3ed is a free software; you can redistribute it and/or modify it under the terms of the GNU General `
`+//Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) `
`+//any later version.`
`+//`
`+//This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the `
`+//implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public `
`+//License for more details.`
`+//`
`+//You should have received a copy of the GNU General Public License along with this source file; if not, write to the `
`+//Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA`
`+`
`+//Task: Find the number of inversions in the file given. `
`+//The file contains all the 100,000 integers between 1 and 100,000 (including both) in some random order(no integer is repeated).`
`+package main`
`+`
`+import (`
`+	"fmt"`
`+)`
`+`
`+func main() {`
`+	//The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?`
`+	/*`
`+	*/`
`+	var maxPFactor uint32=0`
`+	fmt.Printf("FMax prime factor=%d\n",maxPFactor)`
`+}`