lundi 27 juillet 2020

Amazon quick online assesment example [closed]

I'm new to swift and I solved this using java, but I want to see solution using swift by a person who is more experienced in the language (SWIFT)

the greatest common divisor(GCD), also called highest common factor(HCF) of N numbers is the largest positive integer that divides all numbers without a remainder. write an algorithm to determine the GCD of N positive integers.

the input of the function consists of two arguments - (num : Int, arr: [Int]) -> Int
num is the number of positive integers(N), arr is a list of positive integers

input// num=5 , arr=[2,4,6,8,10] output// 2 input// num=5 , arr=[2,3,4,5,6]. output// 1

Aucun commentaire:

Enregistrer un commentaire