Square-free number
A square-free number is a natural number that contains no powers greater than 1 in its prime factorization. In other words, if is our number, and is the prime factorization of into distinct primes, then is always false for square-free .
Note: we assume here that itself must be greater than 1; hence 1 is not considered square-free. However, one must be alert to the particular context in which “square-free” is used as to whether this is considered the case.
The name derives from the fact that if any were to be greater than or equal to two, we could be sure that at least one square divides (namely, .)
A number is called a square free number if there does not exist a number greater than 1, whose square divides the number evenly/perfectly. For example, number 8 is not a square free number as number 4 (which is square of 2), divides 8. Similarly, number 4 is also not a square free number. However numbers 1, 3, 6 all are square free numbers.
Code of Square- free Number: C program !
#include
int isSquareFree(int n)
{
int i;
for(i=2;i<=n; i++)
if(n%i==0)
if(n%(i*i)==0)
return 0;
return 1;
}
int main()
{
int number;
loop:
printf("Enter a number to check it's a Square-free Number or not: ");
scanf("%d",&number);
if(isSquareFree(number)==1)
printf("Square-free Number!\n\n");
else
printf("Not Square-free Number!\n\n");
goto loop;
return 0;
}
Output:
Enter a number to check it's a Square-free Number or not:6
Square-free Number!
Enter a number to check it's a Square-free Number or not:9
Not Square-free Number!