#include <stdio.h>
int digit_sum(int);
int digit_sum_rec(int);
main()
{
int num;
printf("Enter 5 digit positive integer. : ");
scanf("%d",&num);
printf("The sum of the digits is: %d\n",digit_sum(num));
printf("The sum of the digits is (calculated recursively): %d\n",
digit_sum_rec(num));
}
int digit_sum(int n)
{
int t=0;
while(n) {
t+=n%10;
n/=10;
}
return t;
}
int digit_sum_rec(int n)
{
if(n==0) return 0;
return (n%10)+digit_sum_rec(n/10);
}
A linear function is increasing if it has a positive slope. To find this easily, put the function into the form y=mx+b. If m is positive, the function is increasing. If m is negative, it is decreasing.
The logarithmic function is not defined for zero or negative numbers. Logarithms are the inverse of the exponential function for a positive base. Any exponent of a positive base must be positive. So the range of any exponential function is the positive real line. Consequently the domain of the the inverse function - the logarithm - is the positive real line. That is, logarithms are not defined for zero or negative numbers. (Wait until you get to complex analysis, though!)
the range is a positive real number
Increment
A positive gradient is a characteristic of a function whose value increases as the value of the argument increases. So, if y is a function, f(x), of x, then an increase in the value of x is accompanied by an increase in the value of y.
Recursion is a programming technique where a function calls itself to solve a problem. An example of recursion is the factorial function, which calculates the product of all positive integers up to a given number. For instance, the factorial of 5 (written as 5!) is calculated as 5 x 4 x 3 x 2 x 1 120. In this calculation, the factorial function calls itself with a smaller number until it reaches the base case of 1.
A recursive method (or function) is one that calls itself. Here is a popular example: The factorial function n! (read the exclamation mark as: factorial of n, or n factorial), for a positive integer, is the product of all numbers up to that number. For example, 4! = 1 x 2 x 3 x 4. In math, the factorial is sometimes defined as: 0! = 1 n! = n x (n-1)! (for n > 0) You can write a function or method, using this definition. Here is the pseudocode: function factorial(n) if (n = 0) return 1 else return n * factorial(n - 1) Note that this is not very efficient, but there are many problems that are extremely complicated without recursion, but which can be solved elegantly with recursion (for example, doing something with all files in a folder, including all subfolders).
To calculate the direction of a vector, you can use trigonometry. Find the angle the vector makes with the positive x-axis using the arctangent function. This angle represents the direction of the vector in relation to the x-axis.
positive
The factorial f(n) = n * (n-1) * (n-2) * .. 1. For example factorial 5 (written as 5!) = 5 x 4 x 3 x 2 x 1 = 120. The function below returns the factorial of the parameter n. int factorial( int n) { if (n==1) return 1 else return n* factorial( n-1) ; }
false!
The LCM is defined as being a positive integer. Ignore the negative signs. Calculate as if everything's positive.
factorial n is given by formula n! = n.(n-1)....1 int i; long x; x =1; for (i=n;i>1;i--) x = x*i ; will calculate factorial. I have put x as long to avoid integer overflow. checks for n is positive etc. to be added.
The positive regions of a function are those intervals where the function is above the x-axis. It is where the y-values are positive (not zero). The negative regions of a function are those intervals where the function is below the x-axis. It is where the y-values are negative (not zero).
A linear function is increasing if it has a positive slope. To find this easily, put the function into the form y=mx+b. If m is positive, the function is increasing. If m is negative, it is decreasing.
y² = x --> y = ±√x Because there are *two* square roots for any positive number (positive and negative) this will not be a function.
negative