Skip to content

Instantly share code, notes, and snippets.

@Wintus
Last active February 8, 2025 09:54
Show Gist options
  • Save Wintus/a1374141220b9c84116223c48027b30b to your computer and use it in GitHub Desktop.
Save Wintus/a1374141220b9c84116223c48027b30b to your computer and use it in GitHub Desktop.
discrete mathematics
# make Rel in Hasse diagram
# 0 and 1 are trivial and omitted
require 'prime'
Graph = Data.define(:nodes, :edges) do
def initialize(nodes: [], edges: [])
super
end
end
# main
d = Graph.new
Prime.each(9) do |pn|
cod = d.nodes.map { |from| from*pn }
# destructive!
d.edges
.concat(d.nodes.zip(cod))
.concat(cod.map{ |to| [pn,to] })
# destructive!
d.nodes
.append(pn)
.concat(cod)
end
# add square numbers
ss = d.nodes.map { it*it }
d.edges.concat(d.nodes.zip(ss))
d.nodes.concat(ss)
# print
pp d
@Wintus
Copy link
Author

Wintus commented Feb 8, 2025

Vectors of Prime Factors

  • 1; 0,1; 0,0,1; ...
  • 2; 1,1; 0,2; 1,0,1; ...
  • 3; 1,1,1; 2,1; 1,2; ...
  • ...

@Wintus
Copy link
Author

Wintus commented Feb 8, 2025

---
title: Divisor Relation
---
flowchart
	0 -->|⊃| 1
	1 -->|⊃| 2
	1 -->|⊃| 3
	1 -->|⊃| 4
	2 -->|⊃| 4
	1 -->|⊃| 5
	1 -->|⊃| 6
	2 -->|⊃| 6
	3 -->|⊃| 6
	1 -->|⊃| 7
	1 -->|⊃| 8
	2 -->|⊃| 8
	4 -->|⊃| 8
	1 -->|⊃| 9
	3 -->|⊃| 9
	1 -->|⊃| 10
	2 -->|⊃| 10
	5 -->|⊃| 10
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment