Jackpotjoy

# Category Archives: Mathematics

## Project Euler Question 15

Question: Starting in the top left corner of a 2*2 grid, there are 6 routes (without backtracking) to the bottom right corner.How many routes are there through a 20*20 grid? Solution: This is not a particular question for programming ,it seems like a more mathematics  problem for me . for moving from top left to right down , only consist two direction "down/ right", all path is a combination of 20 down and 20 right moves, so ,solution is just number of combination 20 of 40 instruction on move . For Read more [...]

## Project Euler Problem 26

Question A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given: 1/2 = 0.5 1/3 = 0.(3) 1/4 = 0.25 1/5 = 0.2 1/6 = 0.1(6) 1/7 = 0.(142857) 1/8 = 0.125 1/9 = 0.(1) 1/10 = 0.1 Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle. Find the value of d $\lt$1000 for which 1/d contains Read more [...]

## Project Euler Question 14

Question: The following iterative sequence is defined for the set of positive integers: n $\rightarrow$n/2 (n is even) n $\rightarrow$ 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 $\rightarrow$ 40 $\rightarrow$ 20 $\rightarrow$10 $\rightarrow$ 5 $\rightarrow$ 16 $\rightarrow$ 8 $\rightarrow$ 4 $\rightarrow$ 2 $\rightarrow$ 1 It can be seen that this sequence (starting at 13 and finishing Read more [...]

## Project Euler Question 29

Question: Consider all integer combinations of ab for 2 $\leq$ a $\leq$ 5 and 2 $\leq$ b $\leq$ 5: 22=4, 23=8, 24=16, 25=32 32=9, 33=27, 34=81, 35=243 42=16, 43=64, 44=256, 45=1024 52=25, 53=125, 54=625, 55=3125 If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms: 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125 How many distinct terms are in the sequence generated by ab for 2 $\leq$ a $\leq$ 100 Read more [...]

## Project Euler Question 31

Question 31: In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation: 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).x It is possible to make £2 in the following way: 1X£1 + 1x50p + 2x20p + 1x5p + 1x2p + 3x1p How many different ways can £2 be made using any number of coins? Solution : actually this is a linear algebra question : Find all possible $x_{n}$ that satisfy below equation $x_{1}*100+x_{2}*50+x_{3}*20+x_{4}*10+x_{5}*5+x_{6}*2+x_{7}*1=200$ Algorithm Read more [...]

## Project Euler Problem 11 ,13

Problem 11 In the 20*20 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50 32 98 81 28 64 23 67 10 26 38 Read more [...]

## Correlation Analysis of Shibor Rate in R

Correlation is define as degree of  co-movement of two variables . I'll try to analysis the correlation of 7days shibor rate and 1 month shibor rate .  Let's examine the relation in visual first, > ts.plot(shibor$X1W, type="l",col="red") > lines(shibor$X1M, type="l",col="blue") As figure shows , for the most of time 1 Month Shibor rate will be greater than the 1 Week Shibor rate, that makes sense as it require higher return for taking premium Read more [...]

## Implement Exponential Smooth in R

Introduction Exponential Smooth is common technique in time series data analysis . There are 3 types of Exponential smoothing methods , which corresponding to different type of time series data. Time series which don't demonstrate trend or seasonality , use single exponential smoothing Time series which demonstrate trend but not seasonality , use double exponential smoothing  Time series which demonstrate both trend and seasonality , use triple exponential smoothing Single Exponential Read more [...]

## Time Series Analysis on Shibor Rate

R provide powerful functions in time series analysis, I'll try to explore  a few functions regarding to Shibor(Shanghai Interbank Offered Rate) rate from 2006-10-08 to 2012-06-26 . > str(shibor) 'data.frame': 1432 obs. of 9 variables: $Date: Date, format: "2006-10-08" "2006-10-09" ...$ O.N : num 2.12 2.1 2.09 2.1 2.09 ... $X1W : num 2.29 2.3 2.3 2.29 2.29 ...$ X2W : num 2.38 2.4 2.42 2.49 2.52 ... $X1M : num 2.53 2.55 2.57 2.59 2.59 ...$ Read more [...]

## Secant Method in R

Intro The main disadvantage of Newton-Raphson Algorithm is that it require the derivative of original function $f'$ . That create a little mess within R implementation . Scant Method excels in that it only requirement of the function is being continuous . Secant Method Essentially , Secant is much alike to Newton-Raphson Algorithm, difference is that will replace the derivative $f'$ with a analogous expression below: $\frac{f(x_{n}) - f(x_{n-1})}{x_{n} - x_{n-1} }$ First Step, we Read more [...]