This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def gcd_optimized(m, n): | |
| mrcf = 0 # Initialize the most recent common factor variable | |
| for i in range(1, min(m, n) + 1): # Loop through numbers from 1 to min(m, n) | |
| if m % i == 0 and n % i == 0: # Check if 'i' is a common factor of m and n | |
| mrcf = i # Update the most recent common factor | |
| return mrcf # Return the most recent common factor found | |
| # Example usage | |
| gcd_result_optimized = gcd_optimized(8, 12) | |
| print("Optimized GCD:", gcd_result_optimized) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def gcd_using_list(m, n): | |
| common_factors = [] # Initialize an empty list to store common factors | |
| for i in range(1, min(m, n) + 1): # Loop through numbers from 1 to min(m, n) | |
| if m % i == 0 and n % i == 0: # Check if 'i' is a common factor of m and n | |
| common_factors.append(i) # Add to the list of common factors | |
| return common_factors[-1] # Return the last element in the list (largest common factor) | |
| # Example usage | |
| gcd_result = gcd_using_list(8, 12) | |
| print("GCD using list:", gcd_result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Program No: 06 | |
| * Problem statement: Find the area of a triangle | |
| */ | |
| #include <stdio.h> | |
| int main() | |
| { | |
| float base,height,area; | |
| base = 4.0f; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class NightMode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Program No: 02 | |
| Aim : Sum of two integers **/ | |
| #include <stdio.h> | |
| int main(){ | |
| int a,b,sum; | |
| a=10; | |
| b=20; | |
| sum=a+b; |