So i need to generate a 4 digit number that is a perfect square number and also divisible by 63.
Im getting confused as to where I work out the square root and only show whole numbers.
Do I create a new if statement, include it in my original if statement or put in in the same line as my divisible by 63 code?
#include <iostream>
#include <math.h>
int main() {
for(int n = 0001; n<9999; n++)
{
if
(n%63 == 0) //check if divisible by 63
{
std::cout << n << "\t" <<sqrt(n) << std::endl; //numbers and their square root numbers
}
}
return 0;
}
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
// 63 = 7*3*3 so any SQUARE will have to be of the form (square)*7*7*3*3 or square*441
int i1 = sqrt( 999.9 / 441 ) + 1, i2 = sqrt( 9999.9 / 441 );
for ( int i = i1; i <= i2; i++ ) cout << i * i * 441 << ' ';
}