Question

In: Computer Science

Statement: For a given integer N, print all the squares of positive integers where the square...

Statement:

  • For a given integer N, print all the squares of positive integers where the square is less than or equal to N, in ascending order.

Programming Tasks:

  1. Prompt the user to input the value of N
  2. Output to the screen all squares of positive integers <= N

Tests:

Item Test 1 Test 2 Test 3
Inputs: 50 9 100
Outputs: 1 4 9 16 25 36 49 1 4 9 1 4 9 16 25 36 49 64 81 100

Solutions

Expert Solution


Related Solutions

Consider an n×n square board, where n is a fixed even positive integer. The board is...
Consider an n×n square board, where n is a fixed even positive integer. The board is divided into n 2 unit squares. We say that two different squares on the board are adjacent if they have a common side. N unit squares on the board are marked in such a way that every unmarked square on the board is adjacent to at least one marked square. Determine the smallest possible value of N.
Given a list of positive integers c[0...n − 1], and a positive integer v, decides whether...
Given a list of positive integers c[0...n − 1], and a positive integer v, decides whether we can use numbers from c[0...n − 1] to make a sum of v, allowing any particular number in the list to be used multiple times. Or, mathematically, this means that there exists non-negative integer coefficients, x0, x1, ..., xn−1, such that v = x0c[0] + x1c[1] + ...xn−1c[n − 1]. For example, given c[0...3] = {2, 4, 6, 10}, and v = 17,...
For all integers n > 2, show that the number of integer partitions of n in...
For all integers n > 2, show that the number of integer partitions of n in which each part is greater than one is given by p(n)-p(n-1), where p(n) is the number of integer partitions of n.
For each given integer n, determine if n is a sum of two squares. (You do...
For each given integer n, determine if n is a sum of two squares. (You do not have to find the squares.) (a) n = 19 (b) n = 45 (c) n = 99 (d) n = 999 (e) n = 1000
For each given integer n, determine if n is a sum of two squares. (You do...
For each given integer n, determine if n is a sum of two squares. (You do not have to find the squares.) (a)n= 19 (b)n= 45 (c)n= 99 (d)n= 999 (e)n=1000
Prove that the following is true for all positive integers n: n is odd if and...
Prove that the following is true for all positive integers n: n is odd if and only if n2 is odd.
Problem Definition: Problem: Given an array of integers print all pairs of integers a and b...
Problem Definition: Problem: Given an array of integers print all pairs of integers a and b where a + b is equal to a given number. For example, consider the following array and suppose we want to find all pairs of integers a and b where a + b = 16 A= [ 10, 4, 6, 15, 3, 5, 1, 13] The following are pairs that sum to 16: 13, 3 6, 10 15, 1 Your program should print these...
Which positive integers n, where 20 ≤ n ≤ 30, have primitive roots?
Which positive integers n, where 20 ≤ n ≤ 30, have primitive roots?
prove 2 is a factor of (n+1)(n+2) for all positive integers
prove 2 is a factor of (n+1)(n+2) for all positive integers
A positive integer N is a power if it is of the form q^k, where q,...
A positive integer N is a power if it is of the form q^k, where q, k are positive integers and k > 1. Give an efficient algorithm that takes as input a number N and determines whether it is a square, that is, whether it can be written as q^2 for some positive integer q. What is the running time of your algorithm? write the pseudocode for the algorithm.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT