id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

simona1@sfusd.edu > sumOfOddSevenths
prev  |  next  |  chance

Write a function that returns the sum of the first n odd sevenths. So for n=1 it would return 1/7, for n=2 it would return 1/7 + 3/7, for n=4 it would return 1/7 + 3/7 + 5/7 + 7/7, and so on. Note the return type for this function is double. Also note that you should add the numbers in order starting from 1/7. Reversing the order will produce a slightly different result.


sumOfOddSevenths(0) → 0.0
sumOfOddSevenths(1) → 0.14285714285714285
sumOfOddSevenths(2) → 0.42857142857142855

...Save, Compile, Run (ctrl-enter)

public double sumOfOddSevenths(int n){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy