Last active
February 8, 2025 09:54
-
-
Save Wintus/a1374141220b9c84116223c48027b30b to your computer and use it in GitHub Desktop.
discrete mathematics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
pp d |
---
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vectors of Prime Factors