answersLogoWhite

0


Best Answer

Type this into Dev-C++ and run it. You will be able to find whatever harmonic number you want. This may not be perfect because I wrote it in about 10 minutes, but I think it works just fine. Good luck!



#include

double seq(double x);

double seq(double x) {

double temp=0;

if (x==0)
return 0;


return 1/x + seq(x-1);
}


int main() {

double x, y;

while (x != 0) {

printf("Please enter a number:\n");
scanf("%lf", &x);

y = seq(x);

printf("The sequence of that number is: %lf\n", y);

}


system("PAUSE");
return 0;
}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Find Nth harmonic number using recursion?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the algorithm n flowchart for calculating factorial of number using recursion?

A flowchart for factorial of number can be made using different software's. Microsoft Word is the most popular software for beginners to make simple flowcharts.In order to draw the flowchart write the number at the top of the paper and then draw two lines under it going slightly to the sides. Decide what two numbers can be multiplied to equal that number. Keep going until you can no longer get to smaller numbers.


2 Write a program in java to find factorial of a number?

import java.math.BigInteger; public class Factorial { public static void main(String[] args) { BigInteger n = BigInteger.ONE; for (int i=1; i<=20; i++) { n = n.multiply(BigInteger.valueOf(i)); System.out.println(i + "! = " + n); }


What do you mean by base case recursive case binding time runtime stack and tail recursion?

These terms are found in Recursion.1.Base Case:it is the case in recursion where the answer is known,or we can say the termination condition for a recursion to unwind back.For example to find Factorial of num using recursion: int Fact(int num){ if(num==1 num==0)//base casereturn 1;else // recursive case: return num*Fact(num-1);} 2.Recursive case:It is the case whcih brings us to the closer answer. Run Time Stack:It is a system stack us to save the frame stack of a function every recursion or every call.This frame stack consists of the return address,local variables and return value if any. Tail Recursion:The case where the function consist of single recursive call and it is the last statement to be executed.A tail Recursion can be replace by iteration. The above function consists of tail recursion case.where as the below function does not. void binary(int start,int end,int el){int mid;if(end>start){mid=(start+end)/2;if(el==ar[mid])return mid;else{if(el>ar[mid])binary(mid+1,end,ele);elsebinary(start,mid-11,ele);


Algorithm to find factorial using functions?

factorial using recursion style in c++ is unsigned int fact(unsigned int a) { if (a<=1) return 1; else { f*=fact(a-1); return a; } } when using looping structure factorial is unsigned int fact (unsigned int n) { unsigned int i,f=1; for(i=1;i<=n;i++) f*=i ; return f; }


Program to find factorial of a number using inheritance?

/*71.PROGRAM TO FIND FACTORIAL OF A NUMBER USING RECURSION*/ #include<stdio.h> #include<conio.h> int fact(int); void main() { int n,f; clrscr(); printf("Enter number whose factorial is to be calculated: "); scanf("%d",&n); if(n>0) { f=fact(n); printf("factorial of %d is %d",n,f); } else printf("Factorial of numbers less than 1 does not exist"); getch(); } int fact(int n) { int facto=1; if(n>1) facto=n*fact(n-1); else return 1; return(facto); }

Related questions

What are the overheads in using recursion?

Variables that are passed to the function but your teacher wants to know where those variables are stored and why it can be a problem. It is your job to find out, its called learning.


Program to find sum of n numbers using recursion function?

int sum(n) { if (n==0) return 0; else return n+sum(n-1); }


What is the algorithm n flowchart for calculating factorial of number using recursion?

A flowchart for factorial of number can be made using different software's. Microsoft Word is the most popular software for beginners to make simple flowcharts.In order to draw the flowchart write the number at the top of the paper and then draw two lines under it going slightly to the sides. Decide what two numbers can be multiplied to equal that number. Keep going until you can no longer get to smaller numbers.


Program to find a raised to the power b without recursion?

It's pow from math.h


Which is faster to find factorial whether recursive or dowhile?

recursion is always slower than iteration


Find out a car registration number using the chassis number?

You can not find a car registration number using the chassis number. You can only identify it by using the VIN, or vehicle identification number.


2 Write a program in java to find factorial of a number?

import java.math.BigInteger; public class Factorial { public static void main(String[] args) { BigInteger n = BigInteger.ONE; for (int i=1; i<=20; i++) { n = n.multiply(BigInteger.valueOf(i)); System.out.println(i + "! = " + n); }


how to find the owner of a vehicle using the vin number?

how to find the owner of a vehicle using the vin number


Program to find the factorial of a number using recursion?

/*program to find the factorial of a given number*/ #include<stdio.h> #include<conio.h> int fact(int); void main() { int n,c; printf("\n enter the number for which you want to find the factorial"); scanf("%d",&n); c=fact(n); printf("\n the factorial of the number %d is %d",n,fact); getch(); } int fact(int n) { int k; if(n==0) return(1); else k=n*fact(n-1); return(k); }


Find the harmonic mean between 1 and 4?

1.6


What is a Rule using addition to find the multiples of any number?

To find the multiple of a number, add the number to itself.


How do you find your random number for medical counseling?

Using application number