Table of Contents
Print n numbers such that their sum is a perfect square
Sep 09, 2023 pm 09:29 PM
Print
and
perfect square number
Given n numbers, the program must find that the sum of these n numbers is a perfect square number
Input : 5 Output : 1 3 5 7 9 1+3+5+7+9=25 i.e (5)^2
Copy after login
Algorithm
START Step 1 : Declare a Macro for size let’s say of 5 and i to 1 Step 2: loop While till i<=SIZE Step 2.1 -> printing (2*i)-1 Step Step 2.2 -> incrementing i with 1 Step Step3-> End loop While STOP
Copy after login
Example## The Chinese translation of # is:
Example#include <stdio.h>
# define SIZE 5
int main() {
int i=1;
while(i<=SIZE) {
printf("</p><p> %d",((2*i)-1)); i++;
}
}
Copy after login
OutputIf we run the above program, it will generate the following output#include <stdio.h> # define SIZE 5 int main() { int i=1; while(i<=SIZE) { printf("</p><p> %d",((2*i)-1)); i++; } }
Copy after login
1 3 5 7 9
Copy after login
The above is the detailed content of Print n numbers such that their sum is a perfect square. For more information, please follow other related articles on the PHP Chinese website!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
Two Point Museum: Bungle Wasteland Location Guide
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Two Point Museum: Bungle Wasteland Location Guide
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What should I do if the frame line disappears when printing in Excel?

Insufficient memory or disk space to repagin or print this document Word error

Can't print from snipping tool in Windows 11/10

How to print all attachments in Outlook

How to implement printing function in Vue
