Google Search

Sunday, February 14, 2016

Find g.c.d of two number using c program:

‪#‎include‬<stdio.h>
int main(){
int x,y,m,i;
printf("Insert any two number: ");
scanf("%d%d",&x,&y);
if(x>y)
m=y;
else
m=x;
for(i=m;i>=1;i--){
if(x%i==0&&y%i==0){
printf("\nHCF of two number is : %d",i) ;
break;
}
}
return 0;
}

LCM program in c with multiple numbers

#include<stdio.h>
int lcm(int,int);
int main(){

int a,b=1;
printf("Enter positive integers. To quit press zero.");
while(1){
scanf("%d",&a);
if(a<1)
break;
else if(a>b)
b = lcm(a,b);
else
b = lcm(b,a);
}
printf("LCM is %d",b);
return 0;
}
int lcm(int a,int b){
int temp = a;
while(1){
if(temp % b == 0 && temp % a == 0)
break;
temp++;
}
return temp;
}

LCM program in c with two numbers (Other logic) :

#include<stdio.h>
int lcm(int,int);
int main(){
int a,b,l;
printf("Enter any two positive integers ");
scanf("%d%d",&a,&b);
if(a>b)
l = lcm(a,b);
else
l = lcm(b,a);
printf("LCM of two integers is %d",l);
return 0;
}
int lcm(int a,int b){
int temp = a;
while(1){
if(temp % b == 0 && temp % a == 0)
break;
temp++;
}
return temp;
}

Definition of LCM (Least common multiple):

LCM of two integers is a smallest positive integer which is multiple of both integers that it is divisible by the both of the numbers.
For example: LCM of two integers 2 and 5 is 10 since 10 is the smallest positive numbers which is divisible by both 2 and 5.
LCM program in c with two numbers :


‪#‎include‬<stdio.h>
int main(){
int n1,n2,x,y;
printf("\nEnter two numbers:");
scanf("%d %d",&n1,&n2);
x=n1,y=n2;
while(n1!=n2){
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
printf("L.C.M=%d",x*y/n1);
return 0;
}

TYPES OF NUMBER:abundant number

A number that is smaller than the sum of its aliquot parts (proper divisors). Twelve is the smallest abundant number – the sum of its aliquot parts is 1 + 2 + 3 + 4 + 6 = 16 – followed by 18, 20, 24, and 30.
A weird number is an abundant number that is not semiperfect; in other words, n is weird if the sum of its divisors is greater than n, but n is not equal to the sum of any subset of its divisors. The first few weird numbers are 70, 836, 4030, 5830, and 7192. It isn't known if there are any odd weird numbers.
A deficient number is one that is greater than the sum of its aliquot parts. The first few deficient numbers are 1, 2, 3, 4, 5, 7, 8, and 9. Any divisor of a deficient (or perfect) number is deficient. A number that is not abundant or deficient is known as a "perfect number".

TYPES OF NUMBER:algebraic number:

A real number that is a root of a polynomial equation with integer coefficients. For example, any rational number a/b, where a and b are non-zero integers, is an algebraic number of degree one, because it is a root of the linear equation bx - a = 0. The square root of two is an algebraic number of degree two because it is a root of the quadratic equation x2 - 2 = 0. If a real number is not algebraic, then it is a transcendental number. Almost all real numbers are transcendental because, whereas the set of algebraic numbers is countably infinite, the set of transcendental numbers is uncountably infinite (see infinity).

TYPES OF NUMBER: amicable numbers

A pair of numbers, also known as friendly numbers, each of whose aliquot parts add to give the other number. (An aliquot part is any divisor that doesn't include the number itself).
The smallest amicable numbers are 220 (aliquot parts 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, and 110, with a sum of 284) and 284 (aliquot parts 1, 2, 4, 71, and 142, with a sum of 220). This pair was known to the ancient Greeks, and the Arabs found several more. In 1636 Pierre de Fermat rediscovered the amicable pair 17296 and 18416; two years later René Descartes rediscovered a third pair, 9363584 and 9437056. In the 18th century Leonhard Euler drew up a list of more than 60. Then, in 1866, B. Nicoló Paganini (not the violinist!), a 16-year-old Italian, startled the mathematical world by announcing that the numbers 1184 and 1210 were friendly. This second lowest pair of all had been completely overlooked. Today, the tally of known amicable numbers has grown to about two and half million. No amicable pair is known in which one of the two numbers is a square. An unusually high proportion of the numbers in amicable pairs ends in either 0 or 5.