/* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Author: Marco Vitetta E-mail: WebSite: http://ervito.altervista.org */ #include #include #include #include #include int numerical_permutations(long long int NUMBER_OF_ARGUMENTS,...); int prime(long long int VALUE, long long int *PRIMES_ARRAY,...); long long int *primes_below(long long int MAX_VALUE,long long int *PRIMES_NUMBER); void rotate(char *string); int main() { char string[7]; int is_circular,length,rotations_number; long long int *circulars_array=NULL,circulars_number=0,index1=0,index2,number,*primes_array,primes_number=0,rotations_array[6]; primes_array=primes_below(1000000,&primes_number); for(;index11) { int digits_of_the[]={0,0,0,0,0,0,0,0,0,0},index=0,length; char first_argument[20],another_argument[20]; va_list argptr; va_start(argptr,NUMBER_OF_ARGUMENTS); sprintf(first_argument,"%lli",va_arg(argptr,long long int)); length=strlen(first_argument); for(;index0) { int digits_of[]={0,0,0,0,0,0,0,0,0,0}; sprintf(another_argument,"%lli",va_arg(argptr,long long int)); if(length!=strlen(another_argument)) return 0; for(index=0;index2) { long long int test=3; // To verify if it's prime primes_array=malloc(sizeof(long long int)); primes_array[0]=2; *PRIMES_NUMBER=1; for(;testsquare_root || index==*PRIMES_NUMBER) { primes_array=realloc(primes_array,sizeof(long long int)*(*PRIMES_NUMBER+1)); primes_array[*PRIMES_NUMBER]=test; ++*PRIMES_NUMBER; } } } return primes_array; } void rotate(char *string) { char ch; int index=0,length=0; for(;string[length]!='\0';length++); for(ch=string[0];++index