Need to write the statement based on the putty format.. if you type a.out, the f
ID: 3633086 • Letter: N
Question
Need to write the statement based on the putty format..
if you type a.out, the following statement should appear
type a non-negative number: 25 (25 is the input)
type the final number: 35 (35 is the input)
and the output should appear like this:
number # of Pairs
--------- ------------ hint
25 2 25 = (0 * 0 + 5 * 5) 26 = (1 * 1 + 5 * 5) 29 = (2 * 2 + 5 * 5)..... 26 1
27 0
28 0
29 1
30 0
31 0
32 1
33 0
34 1
35 0
the other input is this
type a non-negative number: 1000000000
type the final number: 1000000006
the following output should be like
number # of Pairs
--------- ------------
1000000000 5
1000000001 0
1000000002 0
1000000003 0
1000000004 3
1000000005 0
1000000006 0
Explanation / Answer
I don't know how to use putty programming, but I used some other programming languages.
Here I provide u the method for solving this problem, hope that would help....
Problem has an input number N which may be very big.....
1. read the input N
2. use "for" loop or other similar loop to make "i" changing from 0 to N (round N to closest integer)
3. inside the loop: use similar statement in ur programming language like:
H=(N-i^2); then round (or convert) H to integer "h"
4. then use "if" statement inside the loop:
for example: if (h^2+i^2)==N then count=count+1 (count needs to has initial value of zero before the loop statement)
USING the above method u can find out the number of pairs that u need.....
I don't know about ur programming language so I can't write it........hope the above information helps
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.