/* 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 int pandg(char *STRING,int START); int main() { char concatenation[11],to_concatenate[11]; int max=1,multipler=1,multiplicand; for(;multipler<10000;multipler++) for(multiplicand=1;multiplicand<10000;) { concatenation[0]=to_concatenate[0]='\0'; while(strlen(concatenation)<=9&&(strlen(concatenation)+strlen(to_concatenate))<=9) { sprintf(to_concatenate,"%i",multipler*multiplicand); strcat(concatenation,to_concatenate); multiplicand++; } if(strlen(concatenation)==9&&pandg(concatenation,1)==1&&atoi(concatenation)>max) max=atoi(concatenation); } printf("\n\t%i\n\n",max); return 0; } int pandg(char *STRING,int START) // This function checks if the STRING { // contains all number digits between int length=0,max_value; // START and max_value(which depends // by the length of the STRING and it for(;STRING[length]!='\0'&&length<11;length++); // can't be greater than 10) max_value=length+START; if(length>1 && length<11 && max_value<11 && START>=0 && START<9) { int array[length],index=0,support; for(;index=START && support