<jupyter_start><jupyter_text>Capítol 3 - Algorismes i Nombres  3.2 El Màxim Comú Divisor i les seves aplicacions<jupyter_code>def reduir_fraccio(numerador, denominador):
    divisorsNum = []
    divisorsDen = []
    for i in range(1, numerador+1):
        if(numerador % i ==0):
            divisorsNum.append(i)
        else:
            pass
    for i in range(1, denominador+1):
        if(denominador % i ==0):
            divisorsDen.append(i)
        else:
            pass
    print('els divisorsDen son',divisorsDen)
    print('els divisorsNum son',divisorsNum)
    
    numTeMenysDivs = (len(divisorsNum) < len(divisorsDen))

    minDivs = min(len(divisorsNum), len(divisorsDen))
    
    for i in range (1, minDivs+1):
        for j in range(1, minDivs+1):
            if numTeMenysDivs:
                if(divisorsNum[0-i] == divisorsDen[0-j]):
                    numReduit = numerador//divisorsNum[0-i]
                    denReduit = denominador//divisorsNum[0-i]
                else:
                    pass
            else:
                if(divisorsDen[0-i] == divisorsNum[0-j]):
                    numReduit = numerador//divisorsNum[0-j]
                    denReduit = denominador//divisorsNum[0-j]
                else:
                    pass
    
    
    return (numReduit,denReduit)
    
reduir_fraccio(12,8)
assert reduir_fraccio(12, 8) == (3,2)<jupyter_output>els divisorsDen son [1, 2, 4, 8]
els divisorsNum son [1, 2, 3, 4, 6, 12]
{'fraction_non_alphanumeric': 0.11065573770491803, 'fraction_numerical': 0.0273224043715847, 'mean_word_length': 1.9067460317460319, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '175824', 'license': 'MIT', 'n_tokens_mistral': 538, 'n_tokens_neox': 517, 'n_words': 104, 'path': 'Algorismica/.ipynb_checkpoints/3.2-checkpoint.ipynb', 'repo_name': 'Javiooli/Uni', 'size': '1464'}