Skip to main content
added 552 characters in body
Source Link
user58988
user58988

Axiom, 4545 34 bytes

f(x:PI):Float==reduceAny==sum(+,[11./n for n in 1,n=1..x]x)::Any 

1 Indexed; test-Indexed; It has argument one positive integer(PI) and results:return "Any" that the sys convert (or not convert) to the type useful for next function arg (at last it seems so seeing below examples)

(725) -> [[i,f(i)] for i in 1..9] (725) [[1.0,1.0], [2.0,1.5], [3.0,1.8333333333 333333333],  [4.0,2.0833333333 333333333],  [5.0,2.2833333333 333333333], [6.0,2.45],  [7.0,2.5928571428 571428572],  [8.0,2.7178571428 571428572],  [9.0,2.8289682539 682539683]]   Type: List List Any (26) -> f(3000) (26) 8.5837498899 591871142 Type: Union(Expression Float,...) (27) -> f(300000) (27) 13.1887550852 056117 Type: Union(Expression Float,...) (29) -> f(45)^2 (29) 19.3155689383 88117644 Type: Expression Float 

Axiom, 45 bytes

f(x:PI):Float==reduce(+,[1./n for n in 1..x]) 

1 Indexed; test and results:

(7) -> [[i,f(i)] for i in 1..9] (7) [[1.0,1.0], [2.0,1.5], [3.0,1.8333333333 333333333],  [4.0,2.0833333333 333333333], [5.0,2.2833333333 333333333], [6.0,2.45],  [7.0,2.5928571428 571428572], [8.0,2.7178571428 571428572],  [9.0,2.8289682539 682539683]] Type: List List Float 

Axiom, 45 34 bytes

f(x:PI):Any==sum(1./n,n=1..x)::Any 

1-Indexed; It has argument one positive integer(PI) and return "Any" that the sys convert (or not convert) to the type useful for next function arg (at last it seems so seeing below examples)

(25) -> [[i,f(i)] for i in 1..9] (25) [[1,1.0], [2,1.5], [3,1.8333333333 333333333], [4,2.0833333333 333333333],  [5,2.2833333333 333333333], [6,2.45], [7,2.5928571428 571428572],  [8,2.7178571428 571428572], [9,2.8289682539 682539683]]   Type: List List Any (26) -> f(3000) (26) 8.5837498899 591871142 Type: Union(Expression Float,...) (27) -> f(300000) (27) 13.1887550852 056117 Type: Union(Expression Float,...) (29) -> f(45)^2 (29) 19.3155689383 88117644 Type: Expression Float 
added 12 characters in body
Source Link
user58988
user58988

Axiom, 45 bytes

f(x:PI):Float==reduce(+,[1./n for n in 1..x]) 

1 Indexed; test and results:

(7) -> [[i,f(i)] for i in 1..9] (7) [[1.0,1.0], [2.0,1.5], [3.0,1.8333333333 333333333], [4.0,2.0833333333 333333333], [5.0,2.2833333333 333333333], [6.0,2.45], [7.0,2.5928571428 571428572], [8.0,2.7178571428 571428572], [9.0,2.8289682539 682539683]] Type: List List Float 

Axiom, 45 bytes

f(x:PI):Float==reduce(+,[1./n for n in 1..x]) 

test and results

(7) -> [[i,f(i)] for i in 1..9] (7) [[1.0,1.0], [2.0,1.5], [3.0,1.8333333333 333333333], [4.0,2.0833333333 333333333], [5.0,2.2833333333 333333333], [6.0,2.45], [7.0,2.5928571428 571428572], [8.0,2.7178571428 571428572], [9.0,2.8289682539 682539683]] Type: List List Float 

Axiom, 45 bytes

f(x:PI):Float==reduce(+,[1./n for n in 1..x]) 

1 Indexed; test and results:

(7) -> [[i,f(i)] for i in 1..9] (7) [[1.0,1.0], [2.0,1.5], [3.0,1.8333333333 333333333], [4.0,2.0833333333 333333333], [5.0,2.2833333333 333333333], [6.0,2.45], [7.0,2.5928571428 571428572], [8.0,2.7178571428 571428572], [9.0,2.8289682539 682539683]] Type: List List Float 
Source Link
user58988
user58988

Axiom, 45 bytes

f(x:PI):Float==reduce(+,[1./n for n in 1..x]) 

test and results

(7) -> [[i,f(i)] for i in 1..9] (7) [[1.0,1.0], [2.0,1.5], [3.0,1.8333333333 333333333], [4.0,2.0833333333 333333333], [5.0,2.2833333333 333333333], [6.0,2.45], [7.0,2.5928571428 571428572], [8.0,2.7178571428 571428572], [9.0,2.8289682539 682539683]] Type: List List Float