Skip to content

Instantly share code, notes, and snippets.

@realyukii
Created October 14, 2024 14:29
Show Gist options
  • Save realyukii/7408b8ec746c0fbb797ff3477b5dc03f to your computer and use it in GitHub Desktop.
Save realyukii/7408b8ec746c0fbb797ff3477b5dc03f to your computer and use it in GitHub Desktop.

Revisions

  1. realyukii created this gist Oct 14, 2024.
    28 changes: 28 additions & 0 deletions demo.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #include <stdio.h>

    /*
    * A program to demonstrate inclusion principle in set theory.
    * note: to change the parameter, you need to manually adjust the condition.
    *
    * */
    int main(void)
    {
    int start = 1;
    int end = 100;
    int result = 0;
    int range = 0;

    for (int i = start; i <= end; i++)
    {
    range++;
    if (i%5 == 0 || i%3 == 0) {
    printf("i = %d\n", i);
    result++;
    }
    }

    printf("range: %d\n", range);
    printf("the cardinality of set or collection of A where the elements is smth that can be divided either by 5 or 3 in between of %d to %d is %d\n", start, end, result);

    return result;
    }