Implementation of all sutras in computer lab using C / Python / any other programming language

Lilavati के methods code बनते हैं: Kotlin की कुछ lines part-by-part multiplication और right-triangle check implement करती हैं, classical arithmetic को उस language में एक running program में बदलते हुए जो आपने अभी सीखी।

10 min read · 9 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

Verse से Kotlin तक

पिछले दो topics ने Lilavati की documented mathematics cover की: numbers को parts में तोड़ने वाला एक multiplication method, और right-triangle relationship। आपका syllabus आपसे इनके साथ कुछ satisfying करने को कहता है: इन्हें code में implement करना।

चूँकि यह subject Kotlin है, आप इन्हें उसी language में implement कर सकते हैं जो आपने अभी सीखी, fun, val, और if-expressions को लगभग-900-साल पुरानी mathematics पर apply करते हुए। यह एक normal programming exercise है जो एक classical text को आपकी fresh Kotlin skills से connect करती है। यह lesson दोनों methods short Kotlin programs की तरह दिखाता है, इनके outputs के साथ, ताकि आप Lilavati की arithmetic को एक modern machine पर चलते देख सकें।

Theory

Multiplication Method Implement करना

Lilavati की part-by-part multiplication (topic 1 से) multiplier को place-value parts में तोड़ती है और partial products sum करती है, जो distributive law है। Kotlin में, सबसे simple faithful version multiplier को digit by digit (place value से) process करता है, multiply करता है, और add करता है।

Worked example 125 × 12 के लिए, 12 को 10 + 2 में split करना 125×10 + 125×2 = 1250 + 250 = 1500 देता है। (बेशक Kotlin का * directly multiply करता है; exercise का point documented METHOD को EXPRESS करना है, दिखाते हुए historical technique code में कैसे map होती है, operator को replace करना नहीं।)

Practical

Part-By-Part Multiplication (Documented Method)

// Multiply by breaking the multiplier into place-value parts,
// summing partial products (the Lilavati's distributive method).
fun multiplyByParts(a: Int, b: Int): Int {
    var total = 0
    var place = 1                     // 1, 10, 100, ... (place values)
    for (digit in b.toString().reversed()) {
        total += a * (digit - '0') * place   // digit char -> Int
        place *= 10
    }
    return total
}

fun main() {
    println(multiplyByParts(125, 12))   // 1500
    // 125*2*1 + 125*1*10 = 250 + 1250 = 1500
}

Practical

Kotlin में Right-Triangle Relationship

import kotlin.math.sqrt

// Check the right-triangle relationship: a^2 + b^2 == c^2
fun isRightTriangle(a: Int, b: Int, c: Int): Boolean {
    return a * a + b * b == c * c
}

// Or compute the hypotenuse from the two shorter sides:
fun hypotenuse(a: Int, b: Int): Double {
    return sqrt((a * a + b * b).toDouble())
}

fun main() {
    println(isRightTriangle(3, 4, 5))   // true  (9 + 16 = 25)
    println(hypotenuse(3, 4))           // 5.0
    println(isRightTriangle(3, 4, 6))   // false (9 + 16 = 25, not 36)
}

Quiz

Kotlin function isRightTriangle(a, b, c) return करता है a*a + b*b == c*c। isRightTriangle(3, 4, 5) क्या return करता है, और क्यों?

  1. false, क्योंकि 3 + 4, 5 नहीं है
  2. true, क्योंकि 3*3 + 4*4 = 9 + 16 = 25, और 5*5 = 25, तो equality hold होती है
  3. एक error
  4. true, पर सिर्फ़ coincidence से
Show the answer

true, क्योंकि 3*3 + 4*4 = 9 + 16 = 25, और 5*5 = 25, तो equality hold होती है

Function check करता है aa + bb == cc: 3, 4, 5 के लिए वह left पर 9 + 16 = 25 है और right पर 55 = 25, तो equality hold होती है और यह true return करता है। यह documented right-triangle relationship (West में Pythagorean के नाम से जानी जाती है) correctly implement करता है। Option A sides को square करने की बजाय add करता है (एक common confusion जो code avoid करता है)। Option C ग़लत है: code बिल्कुल fine चलता है। Option D इसे undersell करता है: 3-4-5 का relationship satisfy करना coincidence नहीं है, यह एक genuine right triangle है, correctly identified। यह exercise दिखाता है documented historical mathematics कैसे उस language की कुछ clean lines में directly map होती है जो आपने अभी सीखी।

Think first

जिसे Kotlin * से कर सकता है, उस Method को Implement क्यों करें?

Kotlin एक simple * से multiply करता है, तो Lilavati के part-by-part method को code करने की जहमत क्यों उठाएँ? Educational value क्या है? फिर tap कीजिए।

Show the answer

Value * operator को REPLACE करना नहीं है बल्कि historical method को UNDERSTAND और EXPRESS करना है, और दो चीज़ों को connect करना: classical mathematics और आपकी नई Kotlin skills। Part-by-part multiplication implement करना आपको FORCE करता है समझने के लिए method कैसे काम करता है (place value से split करना, partial products sum करना), जो historical technique AND distributive principle दोनों की आपकी grasp को deepen करता है। यह same educational reason है जिससे आपने कभी sorting को हाथ से implement किया एक library call करने की बजाय: एक method को code करना method सिखाता है। यह यह भी demonstrate करता है कि सदियों पहले की documented mathematics modern code पर cleanly map होती है, समय के across एक nice bridge, और आपको Kotlin की practice देता है। तो यह exercise comprehension और connection के बारे में है, efficiency नहीं। एक algorithm genuinely समझने के लिए, इसे implement कीजिए।

Watch out

Implementation Traps

Squaring की बजाय Sides Add करना: right-triangle check aa + bb == c*c है, a + b नहीं।

c Squared बनाम c: c*c एक 5-side के लिए 25 है; c खुद 5 है (length के लिए square root लीजिए)।

Char से Int: एक digit character convert करने के लिए (digit - '0') चाहिए, char directly नहीं।

Float Comparison: sqrt एक Double return करता है; exact equality के लिए integer squared-form check (aa + bb == c*c) prefer कीजिए।

Comments में Verse Text Fabricate करना: comments factual रखिए; method cite कीजिए, invented shlokas नहीं।

Theory

Methods Coded; अब Capstone Project

आपने Lilavati के documented methods Kotlin में implement किए हैं, historical mathematics और उस language को bridge करते हुए जो आपने अभी सीखी। पूरे subject का final topic capstone PROJECT है: Units 1 से 3 पर based एक छोटा Kotlin Android application बनाना। अगला lesson इसे अच्छी तरह scope और build करने पर guidance देता है, आपने Advance Mobile Technology में जो कुछ सीखा उसे साथ tie करते हुए।

Summary

Key takeaways

  • Syllabus आपसे Lilavati के documented methods code में implement करने कहता है; यह Kotlin subject Kotlin इस्तेमाल करता है।
  • Part-by-part multiplication (distributive method) multiplier को place value से split करती है और partial products sum करती है: multiplyByParts(125, 12) = 1500।
  • Right-triangle relationship aa + bb == c*c की तरह coded होता है: isRightTriangle(3, 4, 5) true है (9 + 16 = 25)।
  • Hypotenuse को sqrt((aa + bb).toDouble()) की तरह compute कीजिए: hypotenuse(3, 4) = 5.0।
  • Value historical method को समझना और code से connect करना है (और Kotlin की practice करना), operators replace करना नहीं।
  • Float comparison पर integer squared-form check prefer कीजिए; comments factual रखिए (कोई fabricated verses नहीं)।
  • Memory hook: documented math Kotlin की कुछ clean lines में map होती है।

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Indian knowledge system of Mathematics

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Implementation of all sutras in computer lab using C / Python / any other programming language · Advance Mobile Technology - I (Major-11-02) · Gri-Learn