Easy Sequences 104: One-line Code Challenge - GCDs of Sum of Consecutive Cubes - MATLAB Cody - MATLAB Central

Problem 57839. Easy Sequences 104: One-line Code Challenge - GCDs of Sum of Consecutive Cubes

Difficulty:Rate
For a natural number, n, the function CC(n) is defined as follows:
In other words, CC(n) is the sum of cubes of all integers from 1 to n.
Given positive integers x and y, write a function that calculates the value of gcd(CC(x),CC(y)) . For example:
>> CC = @(n) sum((1:n).^3);
>> gcdCC = @(x,y) gcd(CC(x),CC(y));
>> gcdCC(5,10)
ans = 25
The following restrictions apply:
  • The function should only have one (1) line of code, excluding the function start line.
  • Semicolons (;) are considered end-of-line characters.
  • Please suppress the function end line. Keyword 'end' is not allowed.
  • Regular expressions are not allowed.
  • Only 'pure' matlab functions/commands are allowed (no java, no python).

Solution Stats

77.78% Correct | 22.22% Incorrect
Last Solution submitted on Apr 24, 2025

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers5

Suggested Problems

More from this Author116

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page