tests
unknown
typescript
a year ago
376 B
5
Indexable
function calcHandshakes(persons: number) {
return (Math.pow(persons-1, 2) + persons-1) / 2
// Математическое решение через треугольные числа
}
function calcHandshakesAlternative(n: number):number {
if(n === 1) return 0
return n-1+calcHandshakesAlternative(n-1)
// Решение через рекурсию
}
Editor is loading...
Leave a Comment