Just regular adds and subtracts, or bit level also? Like break numbers up into individual bits.ermines said:hmmm i've just finished the codes for *, /, %, and cube but they're all in int forms. is there a way to do this in float or double???
right now, i'm having a hard time implementing the cube, raised to any exponent and the square root.
For what type of numbers? int,float,double,...ermines said:I'm trying to implement *, /, %, powers, and square root.
This may not be the most efficient method, but try this:ermines said:i already got it, i think. here's my revised code. pls check if there is more needed to be added.
int inv (int n)
{
int a=1;
if (n>=0)
{
while (n>=1)
{
a++;
n=n/a;
}
a--;
}
return a;
}
now all i need is the code for listing all non-prime numbers from 1-100 including 100. any tips?
for (int i = 1; i <= 100; i++) {
for (int j = 2; j < i; j++) {
if (Modulus(i, j) == 0) {
cout << i << endl;
break;
}
}
}
for (int i = 1; i <= 100; i++) {
for (int j = 2; j < i; j++) {
if (i % j == 0) {
cout << i << endl;
break;
}
}
}