What are the factors that decide the cost of SEO ? |
+0 forum
11 | ||

I have to find factors of 1-10 then count all factors and find if they are odd/even. I know how to find if they are even or odd i just can't count how many factors for each number. #include <iostream.h> #include <stdlib.h> int main() { int num, icntA, icntB, icntC, sub = 0.0; int total = 0.0; cout << "Please enter a positive maxiumum integer value you wish to find divisors: \n"; cin >> num; for(icntA = 1; icntA <= num; icntA++) { for(icntB = 1; icntB <= num; icntB++) { if(icntA % icntB == 0) cout << icntB << … |
+0 forum
1 | ||

I'm working on a program that lists a numbers prime factors. I've finished the bulk of the work and all I have left is the first print where it says the number is prime or composite. I know the way I'm going at it is wrong because it wont work with an if or while. [CODE]int x; int prime = 0; cout << "Please enter a number: "; cin >> x; for (int i=2; i <= x; i++){ if(x % i == 0){ prime = 0; } else{ prime = 1; } } if(prime = 1){ cout << x << … |
+0 forum
7 | ||

hi im told to make a program where the user enters a large number like 13195 and the prgrams gives it the highest prime factor, which i 29. now i have to do this using recursion in basic c, without using loops of any kind, so noo for, while etc. prof showed a way to call the funtion again by it self but dont really get him so thats why need a bit of help.. [CODE]#include<stdio.h> #include <math.h> int main() { long int num; long int prime(long int num); long int primefactor(long int num); printf("Enter the number whose prime factors … |
+0 forum
1 | ||

Code Snippet
Numbers which divide a number Here another small snippet of mathematical nature returning all possible divisors of number. (set is, by the way, needed because of perfect squares Not possible to edit the snippet part but here the same with less stupid command line interface (not repeating the loop): [CODE]def divides(n): return sorted(set(sum( ([x,n/x] for x in range(1, int(n**0.5+0.5) + 1) if not n%x), [] ))) if __name__ =='__main__': import sys sequence = map(int, sys.argv[1:]) if sys.argv[1:] else (45, 53, 64,1231435) for number in sequence: print( "%s divides %i " % (', '.join(map(str, divides(number))), number) ) [/CODE] Without set: [CODE]def divides(n): return sorted(sum( ([x,n/x] if … |
+1 forum
6 |

The End.