Created
March 22, 2016 20:13
-
-
Save zafercavdar/e69c0a0a52c9cab0e7a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Zafer Çavdar | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
printf("Give me N: "); | |
int N; | |
int i, j,k; | |
scanf("%d",&N); | |
int maxNum = 0; | |
int maxPrimeDivisor = 0; | |
for (i = 1; i <= N; i++) { | |
int primeCounter = 0; | |
for (j = 2; j < i; j++) { | |
int isPrime = 1; | |
for (k = 2; k < j; k++) { | |
if (j%k == 0){ | |
isPrime = 0; | |
break; | |
} | |
} | |
if (i%j == 0 && isPrime == 1) { | |
primeCounter++; | |
} | |
} | |
if (primeCounter > maxPrimeDivisor) { | |
maxNum = i; | |
maxPrimeDivisor = primeCounter; | |
} | |
} | |
printf("%d %d\n",maxNum, maxPrimeDivisor); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment