5 kyu

Is my friend cheating?

6,148 of 18,256g964

Description:

  • A friend of mine takes the sequence of all numbers from 1 to n (where n > 0).
  • Within that sequence, he chooses two numbers, a and b.
  • He says that the product of a and b should be equal to the sum of all numbers in the sequence, excluding a and b.
  • Given a number n, could you tell me the numbers he excluded from the sequence?

The function takes the parameter: n (n is always strictly greater than 0) and returns an array or a string (depending on the language) of the form:

[(a, b), ...] or [[a, b], ...] or {{a, b}, ...} or or [{a, b}, ...]

with all (a, b) which are the possible removed numbers in the sequence 1 to n.

[(a, b), ...] or [[a, b], ...] or {{a, b}, ...} or ... will be sorted in increasing order of the "a".

It happens that there are several possible (a, b). The function returns an empty array (or an empty string) if no possible numbers are found which will prove that my friend has not told the truth! (Go: in this case return nil).

Examples:

removNb(26) should return [(15, 21), (21, 15)]
or
removNb(26) should return { {15, 21}, {21, 15} }
or
removeNb(26) should return [[15, 21], [21, 15]]
or
removNb(26) should return [ {15, 21}, {21, 15} ]
or
removNb(26) should return "15 21, 21 15"

or

in C:
removNb(26) should return  {{15, 21}{21, 15}} tested by way of strings.
Function removNb should return a pointer to an allocated array of Pair pointers, each one also allocated. 

Note

See examples of returns for each language in "RUN SAMPLE TESTS"

Fundamentals
Mathematics
Puzzles

Stats:

CreatedMay 4, 2015
PublishedMay 5, 2015
Warriors Trained77420
Total Skips22165
Total Code Submissions132582
Total Times Completed18256
Python Completions6148
Ruby Completions488
C# Completions1091
Java Completions1985
Clojure Completions87
JavaScript Completions4136
Haskell Completions292
CoffeeScript Completions29
TypeScript Completions567
C++ Completions1344
Elixir Completions101
PHP Completions510
Crystal Completions13
F# Completions58
C Completions315
Rust Completions413
Swift Completions244
Go Completions458
R Completions66
Shell Completions32
OCaml Completions27
Fortran Completions10
Julia Completions46
Scala Completions162
PowerShell Completions27
Nim Completions12
Racket Completions22
Reason Completions3
Kotlin Completions213
Prolog Completions13
Pascal Completions7
Factor Completions10
Raku Completions5
Perl Completions16
Elm Completions4
COBOL Completions9
D Completions5
Erlang Completions10
Total Stars1846
% of votes with a positive feedback rating89% of 2145
Total "Very Satisfied" Votes1746
Total "Somewhat Satisfied" Votes311
Total "Not Satisfied" Votes88
Ad
Contributors
  • g964 Avatar
  • jhoffner Avatar
  • Abbe Avatar
  • Blind4Basics Avatar
  • wneumann Avatar
  • Voile Avatar
  • rxe Avatar
  • Bubbler Avatar
  • monadius Avatar
  • hobovsky Avatar
  • user8436785 Avatar
  • akar-0 Avatar
  • 4500zenja1 Avatar
Ad