[Question]
  [
# Definition
> 
> In Mathematics, **Harmonic Sequence** refers to a sequence where
> 
> 
> $$a\_n = \frac 1 n$$
> 
> 
> i.e. the \$n\_{th}\$ term of the sequence equals the reciprocal of \$n\$.
> 
> 
> 
---
## Introduction
In this challenge, given a positive integer \$n\$ as input, output the Partial Sum of first \$n\$ terms of the Harmonic Sequence.
---
# Input
You'll be given a positive integer (within the range of numbers supported by your language). It can be either of Signed and Unsigned (depends on you), since the challenge requires only positive integers.
You can take the input in any way except assuming it to be present in a predefined variable. Reading from file, terminal, modal window (`prompt()` in JavaScript) etc. is allowed. Taking the input as function argument is allowed as well.
---
# Output
Your program should output the sum of the first \$n\$ terms of the Harmonic Sequence as a float (or integer if the output is evenly divisible by 1) with precision of 5 significant figures, where \$n\$ refers to the input. To convey the same in Mathematical jargon, you need to compute
$$\sum\_{i=1}^n \frac 1 i$$
where \$n\$ refers to the input.
You can output in any way except writing the output to a variable. Writing to screen, terminal, file, modal window (`alert()` in JavaScript) etc. is allowed. Outputting as function `return` value is allowed as well.
---
# Additional Rules
* The input number can be either of 0-indexed or 1-indexed. You must specify that in your post.
* You must not use a built-in to calculate the partial sum of the first \$n\$ elements. (Yeah, it's for you Mathematica!)
* You must not [abuse native number types to trivialize the problem](https://codegolf.meta.stackexchange.com/a/8245).
* [Standard Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) apply.
---
# Test Cases
The Test Cases assume the input to be 1-indexed
```
Input     Output
1         1
2         1.5
3         1.8333
4         2.0833
5         2.2833
```
---
# Winning Criterion
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins!
  
[Answer]
# Python 3, 27 bytes
```
h=lambda n:n and 1/n+h(n-1)
```
[Answer]
# JavaScript, ~~19~~ 18 bytes
*1 byte saved thanks to @RickHitchcock*
```
f=a=>a&&1/a+f(--a)
```
This is 1-indexed.
```
f=a=>a&&1/a+f(--a)
for(i=0;++i<10;)console.log(f(i))
```
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 5 bytes
```
+/÷∘⍳
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///3/FR2wRt/cPbH3XMeNS7@f//R20TNdQd1XUedS3SUbdV13HUPLQCKGFoYAAA "APL (Dyalog Unicode) – Try It Online")
You can add `⎕PP←{number}` to the header to change the precision to `{number}`.
This is 1-indexed.
### Explanation
```
+/÷∘⍳                     Right argument; n
    ⍳                     Range; 1 2 ... n
  ÷                       Reciprocal; 1/1 1/2 ... 1/n
+/                        Sum; 1/1 + 1/2 + ... + 1/n
```
[Answer]
# Mathematica, ~~21~~ ~~20~~ 16 bytes
This solution is 1-indexed.
```
Sum[1./i,{i,#}]&
```
[Answer]
# PHP, 33 Bytes
1-indexing
```
for(;$i++<$argn;)$s+=1/$i;echo$s;
```
[Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zNbX@n5ZfpGGtkqmtbQMWstZUKda2NdRXybROTc7IVym2/v8fAA "PHP – TIO Nexus")
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 18 bytes
```
n->sum(i=1,n,1./i)
```
1-indexing.
[Try it online!](https://tio.run/nexus/pari-gp#S1OwVfifp2tXXJqrkWlrqJOnY6inn6n5Py2/SCMPKGeoo2BooKNQUJSZVwIUUFLQtQMSaRp5mpqa/wE "Pari/GP – TIO Nexus")
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 11 bytes
```
1.ri,:)f/:+
```
[Try it online!](https://tio.run/##S85KzP3/31CvKFPHSjNN30r7/39TAA "CJam – Try It Online")
1-indexed.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) `-x`, ~~8~~ ~~6~~ ~~5~~ 3 bytes
```
õpJ
```
With some thanks to ETHproductions
[Try it online](http://ethproductions.github.io/japt/?v=1.4.4&code=9XBK&input=NQoteA==)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
İ€S
```
[Try it online!](https://tio.run/##y0rNyan8///IhkdNa4L///9vCgA "Jelly – Try It Online")
1-indexed.
Explanation:
```
İ€S Main link, monadic
İ€         1 / each one of [1..n]
  S Sum of
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~11~~ 10 bytes
*1 byte removed thanks to Erik the outgolfer*
```
ri),{W#+}*
```
This uses 1-based indexing.
[Try it online!](https://tio.run/nexus/cjam#@1@UqalTHa6sXav1/78pAA "CJam – TIO Nexus")
### Explanation
```
ri            e# Read integer, n
  )           e# Increment by 1: gives n+1
   ,          e# Range: gives [0 1 2 ... n]
    {   }*    e# Fold this block over the array
     W#       e# Inverse of a number
       +      e# Add two numbers
```
[Answer]
## Haskell, 20 bytes
```
f 0=0
f n=1/n+f(n-1)
```
## Original solution, 22 bytes
```
f n=sum[1/k|k<-[1..n]]
```
These solutios assumes 1-indexed input. 
[Answer]
# [R](https://www.r-project.org/), 15 bytes
```
sum(1/1:scan())
```
[Try it online!](https://tio.run/nexus/r#@19cmqthqG9oVZycmKehqfnf9D8A "R – TIO Nexus")
[Answer]
## Tcl 38 bytes
```
proc h x {expr $x?1./($x)+\[h $x-1]:0}
```
That's a very dirty hack, and the recursive calls pass literal strings like "5-1-1-1..." until it evaluates to 0.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes
```
LzO
```
[Try it online!](https://tio.run/##MzBNTDJM/f/fp8r//39TAA "05AB1E – Try It Online")
1-indexed.
[Answer]
# 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
```
[Answer]
# Pyth, 5 bytes
```
scL1S
```
[Try it here.](http://pyth.herokuapp.com/?code=scL1S&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5&debug=0)
1-indexed.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 3 bytes
```
ṁ\ḣ
```
[Try it online!](https://tio.run/##yygtzv7//@HOxpiHOxb////fFAA "Husk – Try It Online")
Output is a fraction.
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 3 bytes
```
ɾĖ∑
```
Lame answer, but range -> reciprocal -> sum -> implicit out, same as jelly
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C9%BE%C4%96%E2%88%91&inputs=5&header=&footer=)
# [Vyxal](https://github.com/Lyxal/Vyxal) `s`, 2 bytes
```
ɾĖ
```
2 Bytes w/ -s from @lyxal, -s sums the stack
[Try it Online!](http://lyxal.pythonanywhere.com?flags=s&code=%C9%BE%C4%96&inputs=5&header=&footer=)
[Answer]
# MATL, 5 bytes
```
:l_^s
```
This solution uses 1-based indexing.
Try it at [MATL Online](https://matl.io/?code=%3Al_%5Es&inputs=10&version=20.0.0)
**Explanation**
```
    % Implicitly grab input (N)
:   % Create an array from [1...N]
l_^ % Raise all elements to the -1 power (take the inverse of each)
s   % Sum all values in the array and implicitly display the result
```
[Answer]
# C, 54 bytes
```
i;float f(n){float s;for(i=n+1;--i;s+=1./i);return s;}
```
Uses 1-indexed numbers.
[Answer]
## Haskell, 21 bytes
```
f n=sum$map(1/)[1..n]
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 6 bytes
```
⟦₁/₁ᵐ+
```
[Try it online!](https://tio.run/nexus/brachylog2#@/9o/rJHTY36QPxw6wTt//9N/0cBAA "Brachylog – TIO Nexus")
This is 1-indexed.
### Explanation
```
⟦₁         Range [1, …, Input]
    ᵐ      Map:
  /₁         Inverse
     +     Sum
```
[Answer]
## [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 13 bytes
```
[:|c=c+1/a]?c
```
Explanation
```
[ |        FOR a = 1 to
 :            the input n
   c=c+    Add to c (starts off as 0)
   1/a     the reciprocal of the loop iterator
]          NEXT
?c         PRINT c
```
[Answer]
# [Gol><>](https://github.com/Sp3000/Golfish), 8 bytes
```
F1LP,+|B
```
[Try it online!](https://tio.run/##S8/PScsszvhv6Oju6Wrt7vffzdAnQEe7xun/f0MuIy5jLhMuUy5DAyAyAAA "Gol><> – Try It Online")
### Example full program & How it works
```
1AGIE;GN
F1LP,+|B
1AGIE;GN
1AG       Register row 1 as function G
   IE;    Take input as int, halt if EOF
      GN  Call G and print the result as number
          Repeat indefinitely
F1LP,+|B
F     |   Repeat n times...
 1LP,       Compute 1 / (loop counter + 1)
     +      Add
       B  Return
```
[Answer]
# [Rust](https://www.rust-lang.org/), 36 bytes
```
|n|(1..=n).map(|n|1./n as f64).sum()
```
[Try it online!](https://tio.run/##ZcmxDkVAEEDR3lcM1UzCyHqPgvAvW5hkEzsRuyp8@6JW3nO3PcQkCt46RYIDljmC9KLofg1Vk3T/MZ16omEeldjbFZ80XCvYAM8mDrtHSkO2bk7jojkWx1WUgoboi@2LV7oB "Rust – Try It Online")
Input is an integer, if the input is <=0 the output is zero, and inputting one gets one.
[Answer]
# [J](https://www.jsoftware.com), 9 bytes
```
1#.1%1+i.
```
I'm only posting this because I think it looks really pretty.
[Attempt This Online!](https://ato.pxeger.com/run?1=m70wa8FOJT31NAVbKwV1BR0FAwUrINbVU3AO8nFbWlqSpmux0lBZz1DVUDtTD8LfpMmVmpyRr5CmZqdgZ6WQqadgCpFYsABCAwA)
```
1#.1%1+i.
       i.  NB. range 0..n-1
     1+    NB. add 1
   1%      NB. 1 divided by each element
1#.        NB. sum the result
```
[Answer]
# [Pyt](https://github.com/mudkip201/pyt), 3 bytes
```
ř⅟Ʃ
        implicit input
ř       produces a list containing 1 to n
 ⅟      takes the reciprocals
  Ʃ     sums the list
        (implicit print)
```
[Try it online!](https://tio.run/##K6gs@f//6MxHrfOPrfz/39AAAA "Pyt – Try It Online")
[Answer]
# [Scala](https://www.scala-lang.org/), 47 bytes
[Try it online!](https://tio.run/##HY2xCsIwGIT3PsVROuRHrO3gEogguDg4iZM4pDVtI/WvJHGQ0mevaQ9uuu/jfK17PQ/Vy9QBF20Z4/w0DTrB8syB5Gn4Vr1RthGsVEEFTO8NyrzY8SZC25JmYDHeURbatV7i6Jz@3a/BWW4fJHFjG6AwJogRJcKAPeXN4IyuO4xgqMO6AZ/ohJ6FTzuRMUUrG@MNTSmtxJQsneY/)
```
def h(n:Int):Double=if(n==0)0 else 1.0/n+h(n-1)
```
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `S`, 2 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
RỊ
```
[Try it online!](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPVIlRTElQkIlOEEmZm9vdGVyPSZpbnB1dD01JmZsYWdzPVNl)
#### Explanation
```
RỊ  # Implicit input
R   # One range
 Ị  # Reciprocal
    # Take the sum
    # Implicit output
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 35 bytes
```
float f(n){return n?1./n+f(--n):0;}
```
[Try it online!](https://tio.run/nexus/c-gcc#FYxBDoIwEEWv8oMhmUkBy1ZQL@KGWCZOglNSy4p4dqyr/15e8k9qz2ULM8ZPDhq71@2QJU4ZQsZ7mvOWDHbvu7M5obY1vvjhe6hlvCc14l1ior8qrvBDmRG9RwHnwFhTaUJVHRi1PKxqtBFS5nLyAw "C (gcc) – TIO Nexus")
]