Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int a, b, k;
- scanf("%d%d%d", &a, &b, &k);
- int zbir = 0;
- for(int i = a; i <= b; i++) {
- int broj = i;
- int broj_na_deliteli = 0;
- for(int j = 1; j <= broj; j++) {
- if(broj % j == 0) {
- broj_na_deliteli++;
- }
- }
- int najmal_prethodnik = broj - k;
- if(najmal_prethodnik < 1) {
- najmal_prethodnik = 1;
- }
- int specijalen_broj = 1;
- for(int j = broj - 1; j >= najmal_prethodnik; j--) {
- int deliteli = 0;
- for(int l = 1; l <= j; l++) {
- if(j % l == 0) {
- deliteli++;
- }
- }
- if(deliteli >= broj_na_deliteli) {
- specijalen_broj = 0;
- }
- }
- if(specijalen_broj == 1) {
- zbir += broj;
- }
- }
- printf("%d\n", zbir);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment