Program in c which finds powerful numbers [Solved/Closed]

Report
-
 Assaad -
Hello,i need to write a program in c which can find all the powerful numbes up to 1000...plz help me..it must be ready by thursday...thank you...

1 reply

Posts
19614
Registration date
Wednesday October 8, 2008
Status
Contributor
Last seen
June 15, 2019
2,603
Do you mean Prime Numbers? I have no idea what a powerful number is.
2
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

i will answer you with a link..thanks for your interest:
https://en.wikipedia.org/wiki/Powerful_number
I will answer you with a link..thanks for your interest:
https://en.wikipedia.org/wiki/Powerful_number
> Fatu
#include <iostream>
using namespace std;

int main() {
    int endRange = 500, var1, var2, var3, finalVar;
    for (int counter = 4; counter < endRange = 500; counter++) {
        var1 = counter;
        var2 = 3;
        var3 = 0;
        finalVar = var1;
        while (var1 % 2 == 0) {
            var1 /= 2;
            var3 += 1;
        }

        while ((var2 <= var1) && (var3 != 1)) {
            var3 = 0;
            while (var1 % var2 == 0) {
                var1 /= var2;
                var3 += 1;
            }
            var2 += 2;
        }

        if (var3 > 1)
            cout << finalVar << ' ';
    }
}