GCF (Greatest Common Factor) and Weight Calculation