Share :

For an Excel Formula's variable taking a Range, input row number by the result of a formula
By : Nazeer
Date : March 29 2020, 07:55 AM

Calculate number of perfect squares in a given big range in C
By : Coronel Fernando Car
Date : March 29 2020, 07:55 AM
this one helps. If you just need to count how many perfect squares there are between 1..N all you need to do is: take a square root of N and get its integer value :) Just think about it. For the range 1..10 the correct answer is 3 (1, 4, 9) which is, incidentally, the roundeddown sqrt(10). If you don't want to count 1 as a perfect square  fine, just don't count it. code :
(int)sqrt(N)  (int)sqrt(M)  1

Perfect Number Method w/ Range
By : Audi
Date : March 29 2020, 07:55 AM
hop of those help? You can't put an else statement inside and if statement unless there is another if statement there. Here is the whole code. Also you weren't reading in all the numbers entered. The first for loop should be n1 <= endval; and not n1 < endval; so that it also checks the enval entered. code :
Scanner scanner = new Scanner(System.in);
int counter = 0;
System.out.println("\nPerfect Number Finder Program");
System.out.print("\nEnter the start value: ");
int starval = scanner.nextInt();
System.out.print("Enter the end value:");
int endval = scanner.nextInt();
for (int n1 = starval; n1 <= endval; n1++) {
int sum = 0;
for (int n2 = 1; n2 < n1; n2++) {
if (n1 % n2 == 0) {
sum = sum + n2;
}
}
if (sum == n1) {
System.out.println(n1 + " is a perfect number");
counter ++; //This will add one to the counter if this loop is enterd
}
if(n1 == endval){
System.out.println("FINISHED!");
break;
}
}
//If the counter is 0 then it will display the message
if(counter == 0){
System.out.println("THERE IS NO PERFECT NUMBERS");
}
}

Calculating the number of perfect squares, perfect cubes,etc in a given range?
By : LdoZ
Date : March 29 2020, 07:55 AM
wish of those help Float numbers calculations are not exact. 64**1/3 could have value like ~3.99999975, so floor gives 3. Or 4.000000016, so ceil gives 5 (I did not check real value). You must take numerical errors into account.

Not counting number of perfect numbers within a range?
By : nyron waite
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I want to find the number of the perfect numbers in a range. This is what i have done so far. , Need to make sum=0 for every input. For e.g code :
if(sum == i) {
count++;
}
sum = 0; /* add this line here */
for(int i=x;i<=y;i++) {
sum = 0; /* or make sum as 0 here */
for(int j=1; j<i; j++) {
if(i%j == 0) {
sum=sum+j;
}
}
if(sum == i) {
count++;
}
}

