#coding in C

12 messages · Page 1 of 1 (latest)

daring bison
#

Might I get how to order an array of int in a crescent form ( 1,2,3) . And for the MCM ( minimum common multiplier).

Thank you in advise

shrewd marten
#

another is LCM

#

to sort an array of integers in ascending order, u can use an sorting algorithm

#

one of the simplest and most commonly used methods in many programming languages in the built in sort function

#

an example in python

#

Given array of integers

arr = [5, 2, 9, 1, 5, 6]

Sorting the array in ascending order

arr.sort()

Output the sorted array

print("Sorted array:", arr)

#

your output likely be

#

Sorted array: [1, 2, 5, 5, 6, 9]

#

LCM of a set of integers is the smallest positive integer that's divisible by all of the integers in the set

#

you can use the relationship between the GCD / LCM

#

LCM(a,b)=|a×b|/GCD(a,b)

#

for more than 2 numbers, you can iteratively apply the LCM function