Working with large numbers
1
Name:
Anonymous
2010-09-27 19:45
I'm creating a program in C that factors a really, really large number(600851475143). What data type should I be using?
Also, my compiler told me that I cannot use the modulus operator with the previously stated number and long type number. How do I fix this?
2
Name:
Anonymous
2010-09-27 19:47
Use long long, and declare the number as 600851475143LL
3
Name:
Anonymous
2010-09-27 19:53
>>2
Thanks for the help, friend!
4
Name:
Anonymous
2010-09-27 19:53
use an arbitrary-precision number library
5
Name:
Anonymous
2010-09-27 21:22
GMP. or BigInteger of java. Or just python. java nad python are slow though. But, who cares?
6
Name:
Anonymous
2010-09-27 21:32
http://pastebin.com/xcFgjmsj
Please critique my code.
Disclaimer: I am a faggot.
7
Name:
Anonymous
2010-09-27 23:11
#include <low_primes.h> //Adds an array of primes (long) low_primes[];
I FUCKINGHBT
8
Name:
Anonymous
2010-09-28 1:44
>>6
//No space between ``//'' and the comment text
JAVA101 programmer
9
Name:
Anonymous
2010-09-28 10:40
>>8
That was the worst you noticed, was it?
10
Name:
Anonymous
2010-09-28 10:41
>>6
FUCK YOU
#include <stdio.h>
#include <low_primes.h> //Adds an array of primes (long) low_primes[];
main()
{
long factors[40];
long long number = 600851475143LL;
int i = 0;
int n = 0;
while (low_primes[i] != 99991)
{
if(number%low_primes[i] == 0)
{
factors[i] = low_primes[i];
number/=low_primes[i];
}
if(number == 1 | number == 0)
{
while (n < 40)
{
printf("%l", factors[n]);
n++;
}
break; // BECAUSE FUCK YOU GOTO
// PIG DISGUSTING!!!
}
i++;
}
// BREAK:
// while (n < 40)
// {
// printf("%l", factors[n]);
// n++;
// }
return 0;
}
11
Name:
Anonymous
2010-09-28 10:45
fuck you considered harmful
12
Name:
Anonymous
2010-09-28 10:48
>>10
You haven't even come close to fixing the worst of it, you twit.
13
Name:
Anonymous
2010-09-28 10:54
>>10
I used a
break yesterday. It didn't feel good at all.
14
Name:
Anonymous
2010-09-28 10:55
>>10
break is considered harmful for the same reason
goto is, idiot. Read the fucking paper.
15
Name:
Anonymous
2010-09-28 10:58
>>14
You'd rather put all conditions for breaking out of a loop in its head?
16
Name:
Anonymous
2010-09-28 10:59
>>14
break and goto both have their place. Look at any OS code. goto is used in a lot of places.
17
Name:
Anonymous
2010-09-28 11:10
>>6
That code has so many problems that I don't even want to start listing them.
18
Name:
Anonymous
2010-09-28 11:11
``considered harmful'' considered harmful
19
Name:
Anonymous
2010-09-28 11:12
>>17
Looking at his code makes me feel better about mine.
20
Name:
Anonymous
2010-09-28 11:39
goto BREAK;
IHBT.
21
Name:
Anonymous
2010-09-28 13:13
>>15
Read the fucking paper.
22
Name:
Anonymous
2010-09-28 13:17
>>21
Flow control considered harmful?
23
Name:
Anonymous
2010-09-28 13:48
>>22
Read the fucking paper.
24
Name:
Anonymous
2010-09-28 15:09
>>9
It was the first thing I noticed.
25
Name:
Anonymous
2010-09-28 16:20
>>23
Fuck reading the paper.
26
Name:
Anonymous
2010-09-28 16:26
>>6
here.
I apologize for my use of goto, I understand that it creates spaghetti code on occasion. Thanks to
>>10 for helping me tackle my problem.
Please calm down, I even included a disclaimer in my post.
27
Name:
Anonymous
2010-09-28 17:19
>>26
It's not your use, but your misuse. Any use of goto where anything else that's not incredibly awkward would have worked is misuse; every other use may be ok.
>>10
You helped him!!
29
Name:
Anonymous
2010-12-24 15:47