-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwhile14.java
More file actions
26 lines (22 loc) · 573 Bytes
/
while14.java
File metadata and controls
26 lines (22 loc) · 573 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package whileGita;
import java.util.Scanner;
public class while14 {
public static void main(String[] args) {
float a;
Scanner scanner=new Scanner(System.in);
System.out.print("A:");
a = scanner.nextInt();
int k = 0;
float temp = 0F;
while (temp <= a)
{
++k;
temp += 1 / (float)k;
}
System.out.print("K:");
System.out.print(k - 1);
System.out.print("\n");
System.out.print("Nsum:");
System.out.print(temp - 1 / (float)k);
}
}