4 kyu
Sum by Factors
4,615 of 20,052g964
Description:
Given an array of positive or negative integers
I= [i1,..,in]
you have to produce a sorted array P of the form
[ [p, sum of all ij of I for which p is a prime factor (p positive) of ij] ...]
P will be sorted by increasing order of the prime numbers. The final result has to be given as a string in Java, C#, C, C++ and as an array of arrays in other languages.
Example:
I = [12, 15]; //result = [[2, 12], [3, 27], [5, 15]]
[2, 3, 5] is the list of all prime factors of the elements of I, hence the result.
Notes:
- It can happen that a sum is 0 if some numbers are negative!
Example: I = [15, 30, -45] 5 divides 15, 30 and (-45) so 5 appears in the result, the sum of the numbers for which 5 is a factor is 0 so we have [5, 0] in the result amongst others.
- In Fortran - as in any other language - the returned string is not permitted to contain any redundant trailing whitespace: you can use dynamically allocated character strings.
Arrays
Algorithms
Mathematics
Similar Kata:
Stats:
Created | Feb 6, 2015 |
Published | Feb 6, 2015 |
Warriors Trained | 78343 |
Total Skips | 24396 |
Total Code Submissions | 187599 |
Total Times Completed | 20052 |
Java Completions | 2278 |
Python Completions | 6863 |
C# Completions | 1212 |
Ruby Completions | 770 |
Clojure Completions | 100 |
Haskell Completions | 191 |
JavaScript Completions | 4615 |
CoffeeScript Completions | 38 |
C++ Completions | 1223 |
TypeScript Completions | 456 |
Elixir Completions | 75 |
PHP Completions | 322 |
Crystal Completions | 18 |
C Completions | 556 |
Rust Completions | 526 |
Swift Completions | 178 |
F# Completions | 51 |
R Completions | 76 |
Shell Completions | 36 |
OCaml Completions | 31 |
Kotlin Completions | 228 |
Fortran Completions | 10 |
Groovy Completions | 13 |
Julia Completions | 38 |
Scala Completions | 125 |
PowerShell Completions | 21 |
Go Completions | 399 |
Nim Completions | 12 |
Reason Completions | 3 |
Racket Completions | 20 |
VB Completions | 14 |
Haxe Completions | 12 |
CommonLisp Completions | 54 |
Dart Completions | 105 |
Lua Completions | 48 |
Pascal Completions | 9 |
Perl Completions | 16 |
Elm Completions | 4 |
COBOL Completions | 7 |
D Completions | 7 |
Erlang Completions | 7 |
Prolog Completions | 9 |
Total Stars | 1688 |
% of votes with a positive feedback rating | 89% of 2338 |
Total "Very Satisfied" Votes | 1892 |
Total "Somewhat Satisfied" Votes | 376 |
Total "Not Satisfied" Votes | 70 |