Generation

generate functionMon, 15 May 2023

The number 3025 has the following characteristic: 30 + 25 = 55 -> 55*55 = 3025. Write a program to obtain all 4-digit numbers with the same characteristic as the number 3025.

#include <stdio.h> int main(){ int n, n1, n2, n3, n4, tmp; for(n=3025; n<=9999; n++){ n1 = n % 10; n2 = (n % 100)/10; n3 = (n % 1000)/100; n4 = n / 1000; tmp = (n1 + n2)*(n1 + n2); if(n3 == n4 && tmp == n){ printf("%d\n", n); } } return 0; }

Want to kickstart your project?Use the new AI Studio to create your code