Question

It is my question : how to write the formula of hoarmnic numbers in vba {1+1/2+1/3+1/4+....)...

It is my question :

how to write the formula of hoarmnic numbers in vba {1+1/2+1/3+1/4+....)

the sum is 10 and i would like to find the terms .....

thanks for your help

Another question :

thanks for your reply. How about the solution in visual basic?

thanks a lot

Homework Answers

Answer #1

First Question :

You don't need to write the formula. Simply use for loop and a variable of double type to add the values in to your final sum. Please find below program to understand it more.

Second Question :

Below is the program to find out sum of first n harmonic terms.

using System;  
public class Exercise19  
{  
    public static void Main()
{
   int i,n;
   double s=0.0;
   
        Console.Write("\n\n");
    Console.Write("Calculate the harmonic series and their sum:\n");
    Console.Write("----------------------------------------------");
    Console.Write("\n\n");   
   
   Console.Write("Input the number of terms : ");
   n= Convert.ToInt32(Console.ReadLine());    
   Console.Write("\n\n");
   for(i=1;i<=n;i++)
   {
     Console.Write("1/{0} + ",i);
     s+=1/(float)i;
   }
   Console.Write("\nSum of Series upto {0} terms : {1} \n",n,s);
 } 
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For the sequence 8x + 4, 7x + 3, 6x + 2, 5x +1, ... ,...
For the sequence 8x + 4, 7x + 3, 6x + 2, 5x +1, ... , a. Identify the next 3 terms. b. Is the sequence arithmetic or geometric? How do you know? c. Find the explicit and recursive formulae for this sequence. d. Write out the sum formula for the first 20 terms and evaluate. e. Write your process to part (d) in Sigma Notation.
I'll get a question like the one below and my professor says that we need to...
I'll get a question like the one below and my professor says that we need to find all three equivalence points in order to know what stage we are in. I know how to find the first equivalence point, but I don't know how to find the 2nd and 3rd equivalence point. Please show me how to calculate all equivalence points for the problem below. Thanks for your help!!! 20.0mL of 0.050M phosphoric acid is titrated with 0.100M NaOH.(Ka1=7.11 x10-3,...
Use C++ Write a program that first reads in how many whole numbers the user wants...
Use C++ Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers, and finally outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the numbers just once each and the user can enter them...
This is a post lab question for my organic chemistry 1 lab course and I just...
This is a post lab question for my organic chemistry 1 lab course and I just cannot seem to find the answer Our lab is preparation and observation of a temperature- dependent liquid crystal display. We melted cholesteryl pelargonate and cholesteryl oleyl carbonate together between two microscope slides and observed the blue/irridescence color that appeared. post lab question i need help with: if your liquid crystal mixture is iridescent at about 15 degrees Celcius, how would you change the method...
1- Write a program to print only the even numbers from 100 to 200 2- Write...
1- Write a program to print only the even numbers from 100 to 200 2- Write a program to print the odd numbers from 22 – 99 3- Write a program to calculate howe many even number from 10 to 120 1- Write a program to find only the even numbers for 12 different numbers 2- Write a program to find the odd numbers for 10 different numbers 3- Write a program to calculate howe many even number and how...
Question 1 Write functions that do the following: i) A function that takes 2 arguments and...
Question 1 Write functions that do the following: i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters. ii) A function that takes 2 arguments and returns the difference, iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both. Question 2 Write functions: i) One that prompts a user for 2 numbers. ii) Adds the two numbers if they are...
QUESTION 4 A compound containing only carbon and hydrogen is 80.0% by mass carbon and 20.0%...
QUESTION 4 A compound containing only carbon and hydrogen is 80.0% by mass carbon and 20.0% by mass hydrogen. What is the empirical formula of the compound? A) C20H60 B) C7H20 C) CH3 D) C2H6 E) CH4 QUESTION 5 A compound containing only carbon and hydrogen is 85.7% by mass carbon and 14.3% by mass hydrogen. What is the empirical formula of the compound? A)CH2 B) C2H4 C) CH4 D) C4H8 E) C86H14 can some one plases help me if...
I have a question, which I cannot find the correct solution to from my book. -...
I have a question, which I cannot find the correct solution to from my book. - Your school Ping-Pong team is not performing very well this season. After some rough calculations, you found out that your team's probability of winning a game is about 0.45. A fellow team member want to know more and asked you also to determine the following. a) The probability of the team winning 2 games out of 5 b) The probability of winning 10 times...
write 3-5 sentences reply to this post . I share your thoughts on active euthanasia... Amanda...
write 3-5 sentences reply to this post . I share your thoughts on active euthanasia... Amanda and I are philosophizing, as I think is healthy and humbling to attempt to understanding where or how another persons views are shaped. I agree that to "kill" is wrong, but I also firmly believe there are exceptions. Namely for one, the soldiers we are speaking about and the rights they have in war. Another for me would be the right to kill any...
1) Completely simplify 2) Write the expression cot( in terms of x and y only 3)...
1) Completely simplify 2) Write the expression cot( in terms of x and y only 3) If csc x = 2 and x is in Q I, determine the exact values of sin x and cos x. 4) Use a sum to product formula to rewrite sin 2x – sin 5x as the product of two trig functions. Step by Step please 5) Use a product to sum formula to rewrite sin(2x) * sin(5x) as a sum of two trig...