Skip to content

Instantly share code, notes, and snippets.

@juanfal
juanfal / 00.basicArraySubprograms.cpp
Created November 4, 2024 10:02
basic array subprograms
// 00.basicArraySubprograms.cpp
// juanfc 2024-11-04
//
#include <iostream>
#include <array>
using namespace std;
// consts
const int N=5;
@juanfal
juanfal / 00.quickinit.cpp
Last active November 30, 2024 10:09
array quick init
// 00.quickinit.cpp
// juanfc 2024-11-30
// https://gist.github.com/juanfal/67cf1a014cc6eeb2bd75b26f3d2eb34b
#include <iostream>
#include <array>
using namespace std;
const int N = 3;
const int NN = 100;
@juanfal
juanfal / hanoi.cpp
Created October 23, 2024 20:02
Hanoi towers recursion
// hanoi.cpp
// juanfc 2024-10-23
//
#include <iostream>
using namespace std;
// prototypes
int main()
{
@juanfal
juanfal / t04e04.amicable.cpp
Last active October 27, 2024 20:12
amicable numbers
// t04e04.amicable.cpp
// juanfc 2024-10-23
// amicable numbers
// 284 220
// 1210 1184
// 2924 2620
// 5564 5020
// 6368 6232
// https://gist.github.com/juanfal/e235970d086c69b1d87db0a37c02c895
@juanfal
juanfal / t03e3.nprimes.cpp
Created October 23, 2024 12:59
primes first n function
// t03e3.nprimes.cpp
// juanfc 2024-10-23
//
#include <iostream>
using namespace std;
int main()
{
bool isPrime(int n);
@juanfal
juanfal / 04.fexp.cpp
Last active October 23, 2024 12:50
expr series with functions. Two ways
// 01.exp.cpp
// juanfc 2024-10-23
// expr series with functions. Two ways
// https://en.wikipedia.org/wiki/Taylor_series
// https://gist.github.com/juanfal/99504b4df2590c909b91a7ead0e96c5c
#include <iostream>
using namespace std;
@juanfal
juanfal / l04e01.trianglenum.cpp
Created October 23, 2024 12:28
triangle of numbers non-consecutive function
// l04e01.trianglenum.cpp
// juanfc 2024-10-23
//
//
// \Ej Build a procedure that receives from the main() program the height of the next numerical triangle and prints it:
// Height? 11
// 1
// 232
// 34543
@juanfal
juanfal / 02.exp.cpp
Last active October 22, 2024 18:46
exp n terms 3 calls
// 02.exp.cpp
// juanfc 2024-10-22
// calculate the factorial directly by adding n terms
// of its series development
// Look at https://en.wikipedia.org/wiki/Taylor_series
// https://gist.github.com/juanfal/2b9d94a665b6f730a79a84c98e2d62a6
#include <iostream>
using namespace std;
@juanfal
juanfal / 01.exp.cpp
Last active October 22, 2024 18:48
exp n terms 1 call
// 01.exp.cpp
// juanfc 2024-10-22
// calculate the factorial directly by adding n terms
// of its series development
// Look at https://en.wikipedia.org/wiki/Taylor_series
// https://gist.github.com/juanfal/8c7b827df2417ce271d25a4d06468847
#include <iostream>
using namespace std;
@juanfal
juanfal / 01.exp.cpp
Last active October 22, 2024 18:33
exp x wo subprograms
// 01.exp.cpp
// juanfc 2013-10-11
// calcular el factorial directamente sumando N términos de su
// desarrollo en serie
// ver http://es.wikipedia.org/wiki/Serie_de_Taylor
#include <iostream>
using namespace std;
int main()