Upload files to "true_dock_rider"
This commit is contained in:
1 parent
043311dfe4
commit
dadedd1a41
2 files changed
+100
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int Getting_each_digit(int n)
|
||||
{
|
||||
int cnt = 0;
|
||||
int sum = 0;
|
||||
while (n%10 != 0)
|
||||
{
|
||||
printf("%d \n",n%10);
|
||||
sum += n%10;
|
||||
n = n/10;
|
||||
}
|
||||
|
||||
printf("Final sum is : %d",sum);
|
||||
//return digits_arr;
|
||||
}
|
||||
|
||||
int Getting_each_digit_Recursively(int n)
|
||||
{
|
||||
if (n%10 == 0)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
return n%10 + Getting_each_digit_Recursively(n/10);
|
||||
//printf("%d\n",n%10);
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int n = 9512;
|
||||
|
||||
printf("%d",Getting_each_digit_Recursively(n));
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int Check_Prime(int n)
|
||||
{
|
||||
if (n<=1) return 0;
|
||||
for (int i = 2;i<n;i++)
|
||||
{
|
||||
if (n%i == 0)
|
||||
{
|
||||
// printf("%d is Not prime",n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
//printf("%d is prime",n);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Check_Sphenic(int n)
|
||||
{
|
||||
int divisors[2];
|
||||
int no = 0;
|
||||
int divisor_counter = 0;
|
||||
for (int i=2;i<n;i++)
|
||||
{
|
||||
if (n%i == 0)
|
||||
{
|
||||
if (Check_Prime(i) == 1)
|
||||
{
|
||||
divisors[divisor_counter] = i;
|
||||
divisor_counter++;
|
||||
}
|
||||
no ++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((no == 6) && divisor_counter == 3)
|
||||
{
|
||||
if (divisors[0] && divisors[1] && divisors[2])
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int FindAllSphenic(int n)
|
||||
{
|
||||
if (n<30)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Check_Sphenic(n) == 1)
|
||||
{
|
||||
printf("this goofy num (%d) is sphenic\n",n);
|
||||
}
|
||||
FindAllSphenic(n-1);
|
||||
}
|
||||
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int n = 200;
|
||||
FindAllSphenic(n);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user