Skip to content

Commit

Permalink
finished exercise 35
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan-Birkey committed Mar 7, 2024
1 parent e67ea10 commit 5f2cabe
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/com/github/jonathanbirkey/chapter05/Exercise35.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
* @author : Jonathan Birkey
* @mailto : [email protected]
* @created : 28Feb2024
* <p>(Display leap years) Write a program that displays all the leap years, 10 per line, from
* 101 to 2100, separated by exactly one space. Also display the number of leap years in this
* period.
* <p>(Summation) Write a program to compute the following summation:
* <p>(1/1+sqrt(2)) + (1/sqrt(2)+sqrt(3)) + (1/sqrt(3)+sqrt(4)) + ... + (1/sqrt(624)+sqrt(625))
*/
package com.github.jonathanbirkey.chapter05;

public class Exercise35 {
public static void main(String[] args) {
// TODO: solve
double summation = 0;
for (int i = 1; i <= 624; i++) {
summation += 1 / (Math.sqrt(i) + Math.sqrt(i + 1));
}
System.out.printf("Summation = %f", summation);
}
}

0 comments on commit 5f2cabe

Please sign in to comment.