Results 1 to 5 of 5

Thread: Quick question about harmonics

  1. #1
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default Quick question about harmonics

    In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Write an expression* whose value* is the 8th harmonic number.

    I have tried both of these:


    Code:
    (double)(1 + (1 / 2) + (1 / 3) + (1 / 4) + (1 / 5) + (1 / 6) + (1 / 7) + (1 / 8))
    
    (double)1 + (1 / 2) + (1 / 3) + (1 / 4) + (1 / 5) + (1 / 6) + (1 / 7) + (1 / 8)
    Both are wrong

    Correct Answer that I found!

    Code:
    1.0+(1/2.0)+(1/3.0)+(1/4.0)+(1/5.0)+(1/6.0)+(1/7.0) + (1/8.0)
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  2. #2
    Join Date
    Sep 2013
    Posts
    49
    Mentioned
    1 Post(s)
    Quoted
    40 Post(s)

    Default

    I typed your question into google.com and even though I can not yet post the links of websites I DID find some relevance on yahoo answers that might be of interest

  3. #3
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Quote Originally Posted by JennyCocoX View Post
    I typed your question into google.com and even though I can not yet post the links of websites I DID find some relevance on yahoo answers that might be of interest

    I've already done that and those are no help either. I've tried reading them and their solutions.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by Element17 View Post
    Both are wrong
    What do you mean, both are wrong?

    e: Just wrote this in browser:
    java Code:
    Double HarmonicNumber(int Step)
    {
      return (Step > 1) ? HarmonicNumber(Step-1) + (1/Step) : 1;
    }
    Last edited by masterBB; 09-16-2013 at 05:40 PM.
    Working on: Tithe Farmer

  5. #5
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    What do you mean, both are wrong?

    e: Just wrote this in browser:
    java Code:
    Double HarmonicNumber(int Step)
    {
      return (Step > 1) ? HarmonicNumber(Step-1) + (1/Step) : 1;
    }
    I have the thing called MyCodeLab and it asked for the 8th harmonicNumber and I type both of solutions I posted in and it said they were wrong.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •