Skip to main content
added 24 characters in body
Source Link

Definition

In Mathematics, Harmonic Sequence refers to a sequence where

Harmonic Sequence Equation$$a_n = \frac 1 n$$

i.e. the nth\$n_{th}\$ term of the sequence equals the reciprocal of n\$n\$.


Introduction

In this challenge, given a positive integer n\$n\$ as input, output the Partial Sum of first n\$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\$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\$n\$ refers to the input. To convey the same in Mathematical jargon, you need to compute

Harmonic Sequence Partial Sum of first n terms$$\sum_{i=1}^n \frac 1 i$$

where n\$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


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 , so the shortest code in bytes wins!

Definition

In Mathematics, Harmonic Sequence refers to a sequence where

Harmonic Sequence Equation

i.e. the nth 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

Harmonic Sequence Partial Sum of first n terms

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


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 , so the shortest code in bytes wins!

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


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 , so the shortest code in bytes wins!

Commonmark migration
Source Link

#Definition

Definition

In Mathematics, Harmonic Sequence refers to a sequence where

 

Harmonic Sequence Equation

 

i.e. the nth term of the sequence equals the reciprocal of n.


Introduction

##Introduction InIn this challenge, given a positive integer n as input, output the Partial Sum of first n terms of the Harmonic Sequence.


#Input

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

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

Harmonic Sequence Partial Sum of first n terms

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

Additional Rules


#Test Cases

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

Winning Criterion

This is , so the shortest code in bytes wins!

#Definition

In Mathematics, Harmonic Sequence refers to a sequence where

 

Harmonic Sequence Equation

 

i.e. the nth 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

Harmonic Sequence Partial Sum of first n terms

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


#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 , so the shortest code in bytes wins!

Definition

In Mathematics, Harmonic Sequence refers to a sequence where

Harmonic Sequence Equation

i.e. the nth 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

Harmonic Sequence Partial Sum of first n terms

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


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 , so the shortest code in bytes wins!

deleted 21 characters in body
Source Link
Arjun
  • 5.1k
  • 2
  • 24
  • 56

#Definition

In Mathematics, Harmonic Sequence refers to a sequence where

Harmonic Sequence Equation

i.e. the nth 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

Harmonic Sequence Partial Sum of first n terms

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


#Test Cases

The Test Cases assume the input to be 1-indexed

Input     Output
1         1
2         1.5
3         1.833333333348333
4         2.083333333340833
5         2.283333333342833

#Winning Criterion

This is , so the shortest code in bytes wins!

#Definition

In Mathematics, Harmonic Sequence refers to a sequence where

Harmonic Sequence Equation

i.e. the nth 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

Harmonic Sequence Partial Sum of first n terms

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


#Test Cases

The Test Cases assume the input to be 1-indexed

Input     Output
1         1
2         1.5
3         1.83333333334
4         2.08333333334
5         2.28333333334

#Winning Criterion

This is , so the shortest code in bytes wins!

#Definition

In Mathematics, Harmonic Sequence refers to a sequence where

Harmonic Sequence Equation

i.e. the nth 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

Harmonic Sequence Partial Sum of first n terms

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


#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 , so the shortest code in bytes wins!

Tweeted twitter.com/StackCodeGolf/status/868902424404271105
added 2 characters in body
Source Link
Arjun
  • 5.1k
  • 2
  • 24
  • 56
Loading
added 321 characters in body
Source Link
Arjun
  • 5.1k
  • 2
  • 24
  • 56
Loading
Source Link
Arjun
  • 5.1k
  • 2
  • 24
  • 56
Loading