Skip to content

Conversation

@Varunraj-53
Copy link

@Varunraj-53 Varunraj-53 commented Nov 6, 2025

This pull request adds three new function-based C programs to the file 08_functions.md.
Each example includes clear explanations inside the code comments and follows the existing formatting style.

✅ Added Programs:

  1. GCD & LCM Using Functions

    • Demonstrates reusable functions
    • Shows how LCM is computed using GCD
  2. Perfect Number Function

    • Uses a helper function to sum proper divisors
    • Clearly demonstrates function decomposition
  3. Strong Number Function

    • Uses a precomputed factorial array
    • Highlights modular function design

✅ Why this improves the repository:

  • Adds more real-world examples for beginners
  • Enhances the functions chapter with practical logic-building programs
  • Matches the repository’s structured learning style

Refs #16.

Summary by CodeRabbit

  • Documentation
    • Added three new C programming examples covering mathematical functions and number properties: Greatest Common Divisor/Least Common Multiple calculations, perfect number validation, and Strong number detection. Each example includes input validation, computation logic, and formatted output demonstrations.

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

Added three complete C program code blocks to documentation: gcd_lcm_functions.c (GCD and LCM calculations), perfect_number_function.c (perfect number detection), and strong_number_function.c (strong number validation using precomputed factorials). Each includes functions, input validation, computation logic, and formatted output.

Changes

Cohort / File(s) Summary
Documentation Examples
08_functions.md
Added three new C program code blocks: gcd_lcm_functions.c with gcd() and lcm() functions; perfect_number_function.c with sumOfProperDivisors() for perfect number checking; strong_number_function.c with precomputeFactorials() and isStrong() for strong number validation using factorial precomputation.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant GCD as gcd_lcm<br/>program
    participant Perfect as perfect_number<br/>program
    participant Strong as strong_number<br/>program

    rect rgb(200, 220, 255)
    Note over GCD: Input → GCD/LCM → Output
    User->>GCD: Enter 2 integers
    activate GCD
    GCD->>GCD: Compute gcd()
    GCD->>GCD: Compute lcm()
    GCD-->>User: Display results
    deactivate GCD
    end

    rect rgb(200, 220, 255)
    Note over Perfect: Input → Check divisors → Output
    User->>Perfect: Enter number
    activate Perfect
    Perfect->>Perfect: sumOfProperDivisors()
    Perfect->>Perfect: Compare with input
    Perfect-->>User: Perfect/Imperfect
    deactivate Perfect
    end

    rect rgb(200, 220, 255)
    Note over Strong: Precompute → Input → Check → Output
    Strong->>Strong: precomputeFactorials()
    User->>Strong: Enter number
    activate Strong
    Strong->>Strong: isStrong() checks<br/>digit factorials
    Strong-->>User: Strong/Not Strong
    deactivate Strong
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review correctness of three independent mathematical algorithms
  • Verify input validation and edge case handling in each program
  • Check formatting and output consistency across examples
  • Ensure functions match documented signatures

Poem

🐰 Three functions hop into docs so bright,
GCD and LCM dance left and right,
Perfect numbers checked with proper care,
Strong numbers with factorials rare! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding three function example programs (GCD & LCM, Perfect, Strong) to the documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca0741 and 3affda3.

📒 Files selected for processing (1)
  • 08_functions.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
08_functions.md

206-206: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


207-207: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


208-208: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


209-209: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


210-210: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


210-210: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


211-211: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


211-211: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


212-212: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


213-213: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


214-214: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


217-217: No space after hash on atx style heading

(MD018, no-missing-space-atx)


242-242: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)


248-248: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


249-249: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


250-250: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


251-251: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


252-252: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


252-252: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


253-253: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


253-253: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


254-254: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


255-255: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


256-256: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


259-259: No space after hash on atx style heading

(MD018, no-missing-space-atx)


281-281: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)


290-290: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


291-291: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


292-292: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


293-293: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


294-294: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


294-294: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


295-295: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


295-295: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


296-296: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


297-297: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


298-298: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


301-301: No space after hash on atx style heading

(MD018, no-missing-space-atx)


323-323: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)

🔇 Additional comments (1)
08_functions.md (1)

205-245: Code logic is sound; minor markdown formatting concerns.

The GCD and LCM functions are well-implemented with proper input validation. The Euclidean algorithm is correct, and the LCM calculation avoids overflow via careful casting. However, static analysis flags markdown indentation issues within the C comment block (lines 206–214). These appear to be false positives triggered by the markdown linter interpreting C comment structure, but they may cause CI/CD failures if strict linting is enforced. The code itself requires no changes.

If markdown linting is part of your CI/CD pipeline, consider reformatting the comment block to align with the markdown linter expectations:

~
/*
~
 * gcd_lcm_functions.c
~
 * Demonstrates writing and reusing functions in C.
~
 *
~
 * What it shows:
~
~
 * - Pure functions with clear inputs/outputs
~
 * - Reuse: LCM computed using GCD

(Adjust indentation of list items to start at column 1 within the comment, or rewrite as regular sentences to avoid triggering list-parsing rules.)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Owner

@gpl-gowthamchand gpl-gowthamchand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Varunraj-53, thanks again for these useful function examples! They’ll help learners a lot.

Before we merge, could you make a few small changes so the examples are easier to run and the lesson remains lean?

Requested changes:

  1. Move each program to its own file under contributions/basic_programs/:

    • contributions/basic_programs/gcd_lcm_functions.c
    • contributions/basic_programs/perfect_number_function.c
    • contributions/basic_programs/strong_number_function.c
  2. Add a small header comment to each file with Program, Author, Date, Description, and Usage (compile/run example).

  3. In 08_functions.md keep a short example or link to each .c file instead of embedding the full program inline.

  4. Push the changes to this PR branch once done so authorship is preserved.

If you'd prefer, I can make these changes for you and push them to this branch; I will add a Co-authored-by line to credit you. However, to maximize visible credit it’s best if you push the updates.

Thanks.. ping me when done and I’ll re-review quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants