Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Difference Between a Mathematician and a Programmer

Name: Anonymous 2018-10-02 23:34

Mathematician:
fib(n) = ((1/2+sqrt(5)/2)^n - (1/2-sqrt(5)/2)^n)/sqrt(5)

Programmer:
#include <iostream>
using namespace std;

int main()
{
int n, t1 = 0, t2 = 1, nextTerm = 0;

cout << "Enter the number of terms: ";
cin >> n;

cout << "Fibonacci Series: ";

for (int i = 1; i <= n; ++i)
{
// Prints the first two terms.
if(i == 1)
{
cout << " " << t1;
continue;
}
if(i == 2)
{
cout << t2 << " ";
continue;
}
nextTerm = t1 + t2;
t1 = t2;
t2 = nextTerm;

cout << nextTerm << " ";
}
return 0;
}

Name: Anonymous 2018-10-03 0:02

Mathematician: single-letter variables are good, I like how unreadable it is, and I think other people being confused by my formulas means I'm smart

Programmer: code should be well-documented and easy to understand. Proper naming and commenting are very important.

Who's the real moron?

Name: Anonymous 2018-10-03 0:16

>>2
Formulas are irrelevant in math without detailed proofs written down somewhere. People can just read that for documentation.

It’s much harder to write an unreadable proof than an unreadable program.

In general math is a much better way of expressing concepts because it was meant to be consumed by humans not machines. All math notation is completely declarative (and thus self-documenting). There is no need to free pointers or join threads or any of that mental midget toilet scrubber stuff in math. It just works.

Name: Anonymous 2018-10-03 0:50

>>3
sounds like you're just trying to rationalize being a mathfag instead of a programmer

programmers can make games, botnets, and all sorts of cool shit

mathematician? what do you do, teach students how to do derivatives and integrals even though you have a PhD? lmao most people who study math don't use it, I know someone with a physics degree who works at a tabletop game store

Name: Anonymous 2018-10-03 1:05

Its almost like math is a thousand-year-old field of study, and computer programming is barely older than my great grandparents.

Name: Anonymous 2018-10-03 1:07

>>5
computer science is a subset of math, but it has contributed more to society than math, even in its short life so far

Name: Anonymous 2018-10-03 5:15

Programs are proofs and types are propositions.

Name: Anonymous 2018-10-03 5:42

>>1
C programmer:
#include <stdio.h>
#include <stdlib.h>
#include <math.h> //compile with -O3 fib.c -lm
long double fib(long double n){
return (powl((1.0/2.0+sqrtl(5.0)/2.0),n) - powl((1.0/2.0-sqrtl(5.0)/2.0),n))/sqrtl(5.0);}
int main(int argc,char**argv){if(argc==2){printf("%LG",fib((long double)strtoull(argv[1],NULL,10)));}}
Edited on 03/10/2018 05:47.

Name: Anonymous 2018-10-03 6:02

>>8
after fin(23599) it doesn't work

Name: Anonymous 2018-10-03 6:07

Programmer:
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)

Name: Anonymous 2018-10-03 6:08

>>3
There is no need to free pointers or join threads or any of that mental midget toilet scrubber stuff in math. It just works.
almost if programming (as opposed to pure computer science) was a subset of engineering and not pure abstract math. there is no need to account for gravity, materials and erosion in pure geometry, but it doesn't mean that bridge builders are retards.

>>8
FrozenAnus-tier readability.

Name: Anonymous 2018-10-03 6:09

Name: Anonymous 2018-10-03 6:15

>>12
I am not surprised

Name: Anonymous 2018-10-03 6:52

>>8,12
you're not supposed to code golf with C code

Name: Anonymous 2018-10-03 6:55

>>14
People who are not capable enough to read nontrivial code are not a valid reason to dumb down your code.

Name: Anonymous 2018-10-03 7:06

>>14,15
Its neither code golf nor "non-trivial"
Its just 2 lines of code. I have word-wrap in my editor it looks fine.
I've run it through C beautifier and there isn't much change.
#include < stdio.h >
#include < stdlib.h >
#include < math.h > //compile with -O3 fib.c -lm
long double fib(long double n) {
return (powl((1.0 / 2.0 + sqrtl(5.0) / 2.0), n) - powl((1.0 / 2.0 - sqrtl(5.0) / 2.0), n)) / sqrtl(5.0);
}
int main(int argc, char ** argv) {
if (argc == 2) {
printf("%LG", fib((long double) strtoull(argv[1], NULL, 10)));
}
}

Name: Anonymous 2018-10-03 7:27

>>16
it's actually much better. typesetting and text layout make a difference. read https://practicaltypography.com/

Name: Anonymous 2018-10-03 7:34

Actual Code Golf version(122 bytes) by popular request:
http://void.wikidot.com/code:fib-formula-codegolf-c
#define k long double
main(int b,char**a){k n=(k)atoi(a[1]),z=sqrtl(5);printf("%LG",(powl(0.5+z/2,n)-powl(0.5-z/2,n))/z);}

Name: Anonymous 2018-10-03 8:01

>>18
printf("%LG"
bloat?

Name: Anonymous 2018-10-03 8:02

>>19
How else you expect to print long doubles?

Name: Anonymous 2018-10-03 8:06

print my

Name: Anonymous 2018-10-03 8:06

long dubs

Name: Anonymous 2018-10-03 9:10

>>20
puts

Name: Anonymous 2018-10-03 9:20

>>2
single-letter variables are good, I like how unreadable it is, and I think other people being confused by my formulas means I'm smart

1. single letter variables make patterns easily noticeable
2. they make you think abstract instead of being bound to the notion of counting apples and oranges.
3. mathematics involves large formulas, which are transform in various way, usually manually, so having 2-letter names, instead of 1-letter, means more wasted screen space and work transforming expression.
4. in many cases formulas are enumerated by algorithm, such as the polynomial formulas, so variable names there have no sense. Edited on 03/10/2018 09:25.

Name: Anonymous 2018-10-03 9:21

>>23
dubs should be formatted as integer

Name: Anonymous 2018-10-03 10:00

>>23
puts cannot print anything but zero-terminated strings.

Name: Anonymous 2018-10-03 13:02

>>26
You are correct only if you are still using C89.

Name: Anonymous 2018-10-03 13:17

>>27
What C standard allows puts(long double x) ?

Name: Anonymous 2018-10-03 13:48

>>27
Cease fucktarding immediately

Name: Anonymous 2018-10-03 20:09

>>29
I've PhD in Gender Studies, you retard!

Name: Anonymous 2018-10-03 20:19

>>26-30
Don't fight garls, I am enough for everynyan.
#define puts(x) _Generic((x), long double: printf("%lf\n", (x)), default: puts((x)))

Name: Anonymous 2018-10-03 21:04

>>31
is this in da standard?

Name: Anonymous 2018-10-04 0:44

>>31,32
Thats isn't puts. Its a macro wrapper for printf.

Name: Anonymous 2018-10-04 6:51

>>33
This is C/C++, not GO.

Name: Anonymous 2018-10-04 8:37

>>34
Gender studies confirmed to rot the brain.

Name: Anonymous 2018-10-04 18:41

puts(my_anus);

Name: Einheitliche Feldtheorie 2018-10-04 19:10

lim --> ***

["The stars are the limit."]

Don't change these.
Name: Email:
Entire Thread Thread List