Advertisement
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++) {
- // prvo treba da najdeme kolku deliteli ima brojot i
- int broj_na_deliteli = 0;
- for(int c = 1; c <= i; c++) {
- if(i % c == 0) {
- broj_na_deliteli++;
- }
- }
- int do_kade = i - k;
- if(do_kade < 1) {
- do_kade = 1;
- }
- int k_deliv = 1;
- for(int j = i - 1; j >= do_kade; j--) {
- int deliteli_na_j = 0;
- // so ova gi naogame deliltelite na prethodnicite
- for(int u = 1; u <= j; u++) {
- if(j % u == 0) {
- deliteli_na_j++;
- }
- }
- if(deliteli_na_j >= broj_na_deliteli) {
- k_deliv = 0;
- }
- }
- if(k_deliv == 1) {
- zbir += i;
- }
- }
- printf("%d\n", zbir);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement