Publications by Tony
Project Euler — problem 3
The third problem: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? My solvement is straightforward: firstly to identify all the prime numbers between 2 and sqrt(n); secondly find out the prime factors of this number. ?View Code RSPLUS1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...
1140 sym R (660 sym/2 pcs) 1 tbl
Project Euler — problem 4
It’s midnight already. I’m going to bed after I type this. Now the fourth Euler problem: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers. Mmm … Palindromic. people can tell whether...
1891 sym R (638 sym/2 pcs) 2 img 1 tbl
Project Euler — problem 5
I spent around 40 minutes on the last post yesterday, which delayed my bedding time and caused my sleepiness in the morning. So, I’m starting to write earlier tonight. The fifth problem is to calculate the smallest composite for given numbers. 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any re...
2152 sym R (1592 sym/4 pcs) 2 tbl
Project Euler — problem 6
It’s midnight officially. Let me solve the sixth problem before bed. This is a quick one. The sum of the squares of the first ten natural numbers is, 12 + 22 + … + 102 = 385. The square of the sum of the first ten natural numbers is, (1 + 2 + … + 10)2 = 552 = 3025. Hence the difference between the sum of the squares of the first ten natural...
2004 sym R (115 sym/2 pcs) 2 img 1 tbl
Project Euler — problem 7
Prime is the core of number theory. Here is an introduction of prime number on Wikipedia. I could only understand roughly half of it. Now, let’s look at the seventh problem of Project Euler, which is another about prime number. By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What i...
1737 sym R (327 sym/2 pcs) 1 tbl
Project Euler — problem 8
The eight problem of Project Euler: Find the greatest product of five consecutive digits in the 1000-digit number. … The solution is as straightforward as the problem, although the 1000-digit number needs some format changes before product calculation. ?View Code RSPLUS1 2 3 4 5 6 7 8 tmp <- scan("tmp.txt", what = "") # store the numbers in ...
1423 sym R (1102 sym/4 pcs) 2 tbl
Project Euler — problem 9
Just had supper. My stomach is full of cabbage, carrot and noodle. I’d like to solve the ninth problem to stretch my mind. This one is about Pythagorean theorem. A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2. For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet fo...
1847 sym R (248 sym/2 pcs) 1 tbl
Project Euler — problem 10
Just finish my last assignment for this week. IT’S WEEKEND, officially. Let me take a break to have a look at the tenth problem, another prime problem. It’s no doubt that prime is the center of the number theory and fundamental to arithmetic. No wonder there are so many prime problems in Euler project. Well, enough chatting. Here is the ten...
1664 sym R (670 sym/2 pcs) 1 tbl
google R style guide
After writing several hundreds of lines of R codes, I start to pay some attention to my coding style. Fortunately, I find a document about R style guide in google code. Surprisingly, R is among the most popular programming languages, such as C++, objective-C, python, java and html. I didn’t realize R has become so popular; I thought...
1842 sym
SYTYCD — where are these terrific dancers come from?
It’s Saturday midnight and I’m already sleepy. However, after several hours, I finally got this google geographic map embedded in my post. Aha!!! This is about 20 finalists from the 9th season of So You Think You Can Dance. I count the states where they come from. Then plot the numbers on US map. Here shows the map. SYTYCD2012 Data: dat �...
1035 sym R (635 sym/2 pcs) 1 tbl