Cody

Problem 793. Combinations without using nchoosek

You have to generate a matrix with all possible combinations of n elements taken 2 at a time, without using nchoosek(1:n,2) :

Examples

if n = 3

output =

       1     2
       1     3
       2     3

if n = 5

output = 
       1     2
       1     3
       1     4
       1     5
       2     3
       2     4
       2     5
       3     4
       3     5
       4     5

Good luck!!

Solution Stats

68.52% Correct | 31.48% Incorrect
Last solution submitted on Apr 18, 2016

Solution Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more