Focus mode
Java ile girilen sayının harmonik serisini bulan program yazacağız.
Harmonik Seri Formülü :
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("N sayısını giriniz :");
double n = input.nextInt();
double result = 0;
while (n > 0) {
result += (1 / n);
n--;
}
System.out.println(result);
}
}
Programs to Accelerate Your Progress in a Software Career
Join our 4-8 month intensive Patika+ bootcamps, start with the fundamentals and gain comprehensive knowledge to kickstart your software career!
You need to enroll in the course to be able to comment!