Loops – Arithmetic – Problem #21

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: Hard

Problem Statement

A Ramanujan number is a positive integer that is expressible as the sum of two cubes in two different ways. Write a program that takes an integer n as input and prints all integers less than or equal to n that can be expressed as the sum of two cubes in two different ways, i.e., find distinct positive integers a, b, c, and d such that a3 + b3 = c3 + d3 <= n. Use four nested for loops. The smallest Ramanujan number is 1729, since 103 + 93 = 123 + 13 = 1729. (Please read the 3's as cubes)

Back to Lab Problems
Loops/Arithmetic/Problem #21

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #21

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.