Skip to content

Commit

Permalink
Create harmonik.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Dedos22 authored Jun 1, 2023
1 parent c1b2516 commit 6ae55f6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions harmonik.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import java.util.Scanner;

public class harmonik {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n,i;
double sum = 0;
System.out.print("Which number do you want to find the harmonic series of: ");
n = input.nextInt();

for (i=1;i<=n;i++){
sum = sum + 1.0/i;
}

System.out.println("Sum: " + sum);
}
}

0 comments on commit 6ae55f6

Please sign in to comment.